annotate move-if-change @ 112435:4889fb6961b2

Merge: Promote SSDATA macro to lisp.h.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 22 Jan 2011 18:57:40 -0800
parents 14a97ab281d5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25856
Dave Love <fx@gnu.org>
parents:
diff changeset
1 #!/bin/sh
112150
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
2 # Like mv $1 $2, but if the files are the same, just delete $1.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
3 # Status is zero if successful, nonzero otherwise.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
4
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
5 VERSION='2007-09-28 23:10'; # UTC
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
6 # The definition above must lie within the first 8 lines in order
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
7 # for the Emacs time-stamp write hook (at end) to update it.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
8 # If you change this file with Emacs, please let the write hook
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
9 # do its job. Otherwise, update this string manually.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
10
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
11 # Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
12
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
13 # This program is free software: you can redistribute it and/or modify
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
14 # it under the terms of the GNU General Public License as published by
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
15 # the Free Software Foundation, either version 3 of the License, or
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
16 # (at your option) any later version.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
17
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
18 # This program is distributed in the hope that it will be useful,
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
21 # GNU General Public License for more details.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
22
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
23 # You should have received a copy of the GNU General Public License
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
25
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
26 usage="usage: $0 SOURCE DEST"
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
27
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
28 help="$usage
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
29 or: $0 OPTION
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
30 If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
31
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
32 --help display this help and exit
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
33 --version output version information and exit
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
34
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
35 Report bugs to <bug-gnulib@gnu.org>."
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
36
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
37 version=`expr "$VERSION" : '\([^ ]*\)'`
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
38 version="move-if-change (gnulib) $version
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
39 Copyright (C) 2007 Free Software Foundation, Inc.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
40 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
41 This is free software: you are free to change and redistribute it.
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
42 There is NO WARRANTY, to the extent permitted by law."
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
43
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
44
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
45 for arg
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
46 do
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
47 case $arg in
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
48 --help | --hel | --he | --h)
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
49 exec echo "$help" ;;
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
50 --version | --versio | --versi | --vers | --ver | --ve | --v)
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
51 exec echo "$version" ;;
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
52 --)
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
53 shift
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
54 break ;;
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
55 -*)
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
56 echo "$0: invalid option: $arg" >&2
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
57 exit 1 ;;
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
58 *)
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
59 break ;;
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
60 esac
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
61 done
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
62
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
63 test $# = 2 || { echo "$0: $usage" >&2; exit 1; }
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
64
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
65 if test -r "$2" && cmp -s -- "$1" "$2"; then
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
66 rm -f -- "$1"
25856
Dave Love <fx@gnu.org>
parents:
diff changeset
67 else
112150
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
68 mv -f -- "$1" "$2"
25856
Dave Love <fx@gnu.org>
parents:
diff changeset
69 fi
112150
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
70
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
71 ## Local Variables:
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
72 ## eval: (add-hook 'write-file-hooks 'time-stamp)
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
73 ## time-stamp-start: "VERSION='"
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
74 ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
75 ## time-stamp-time-zone: "UTC"
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
76 ## time-stamp-end: "'; # UTC"
14a97ab281d5 * install-sh, mkinstalldirs, move-if-change: Update from master
Paul Eggert <eggert@cs.ucla.edu>
parents: 25856
diff changeset
77 ## End: