]> git.ipfire.org Git - thirdparty/gcc.git/blame - move-if-change
[Ada] Use new API when creating a special SPARK heap entity
[thirdparty/gcc.git] / move-if-change
CommitLineData
6599da04 1#!/bin/sh
67dc1785
BE
2# Like mv $1 $2, but if the files are the same, just delete $1.
3# Status is zero if successful, nonzero otherwise.
6599da04 4
0c8969f0 5VERSION='2012-01-06 07:23'; # UTC
03b2a04d
RW
6# The definition above must lie within the first 8 lines in order
7# for the Emacs time-stamp write hook (at end) to update it.
8# If you change this file with Emacs, please let the write hook
9# do its job. Otherwise, update this string manually.
6599da04 10
0c8969f0 11# Copyright (C) 2002-2014 Free Software Foundation, Inc.
67dc1785 12
03b2a04d
RW
13# This program is free software: you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation, either version 3 of the License, or
16# (at your option) any later version.
17
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22
23# You should have received a copy of the GNU General Public License
24# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
26usage="usage: $0 SOURCE DEST"
27
28help="$usage
29 or: $0 OPTION
30If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
31
32 --help display this help and exit
33 --version output version information and exit
34
0c8969f0 35The variable CMPPROG can be used to specify an alternative to 'cmp'.
03b2a04d
RW
36
37Report bugs to <bug-gnulib@gnu.org>."
38
39version=`expr "$VERSION" : '\([^ ]*\)'`
40version="move-if-change (gnulib) $version
41Copyright (C) 2011 Free Software Foundation, Inc.
42License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
43This is free software: you are free to change and redistribute it.
44There is NO WARRANTY, to the extent permitted by law."
45
46cmpprog=${CMPPROG-cmp}
47
48for arg
49do
67dc1785 50 case $arg in
03b2a04d
RW
51 --help | --hel | --he | --h)
52 exec echo "$help" ;;
53 --version | --versio | --versi | --vers | --ver | --ve | --v)
54 exec echo "$version" ;;
55 --)
56 shift
57 break ;;
58 -*)
59 echo "$0: invalid option: $arg" >&2
60 exit 1 ;;
61 *)
62 break ;;
67dc1785
BE
63 esac
64done
65
03b2a04d
RW
66test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; }
67
68if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then
69 rm -f -- "$1"
6599da04 70else
03b2a04d
RW
71 if mv -f -- "$1" "$2"; then :; else
72 # Ignore failure due to a concurrent move-if-change.
73 test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1"
74 fi
6599da04 75fi
03b2a04d
RW
76
77## Local Variables:
78## eval: (add-hook 'write-file-hooks 'time-stamp)
79## time-stamp-start: "VERSION='"
80## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
81## time-stamp-time-zone: "UTC"
82## time-stamp-end: "'; # UTC"
83## End: