diff options
| author | Paul Eggert | 2011-01-07 12:42:11 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-01-07 12:42:11 -0800 |
| commit | 2b3f5bc80a2b8a7496a5d87cc98ffcce44e7b32e (patch) | |
| tree | 0f8e136e47266b4bc4fa38ce543686edf4440f8e /move-if-change | |
| parent | f56e0e7a85978026b611bc8f28bdb91d7f8130d4 (diff) | |
| download | emacs-2b3f5bc80a2b8a7496a5d87cc98ffcce44e7b32e.tar.gz emacs-2b3f5bc80a2b8a7496a5d87cc98ffcce44e7b32e.zip | |
* install-sh, mkinstalldirs, move-if-change: Update from master
Diffstat (limited to 'move-if-change')
| -rwxr-xr-x | move-if-change | 86 |
1 files changed, 74 insertions, 12 deletions
diff --git a/move-if-change b/move-if-change index ee9e355e3e6..a891ca51f0c 100755 --- a/move-if-change +++ b/move-if-change | |||
| @@ -1,15 +1,77 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | if | 2 | # Like mv $1 $2, but if the files are the same, just delete $1. |
| 3 | test -r $2 | 3 | # Status is zero if successful, nonzero otherwise. |
| 4 | then | 4 | |
| 5 | if | 5 | VERSION='2007-09-28 23:10'; # UTC |
| 6 | cmp $1 $2 > /dev/null | 6 | # The definition above must lie within the first 8 lines in order |
| 7 | then | 7 | # for the Emacs time-stamp write hook (at end) to update it. |
| 8 | echo $2 is unchanged | 8 | # If you change this file with Emacs, please let the write hook |
| 9 | rm -f $1 | 9 | # do its job. Otherwise, update this string manually. |
| 10 | |||
| 11 | # Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. | ||
| 12 | |||
| 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 | |||
| 26 | usage="usage: $0 SOURCE DEST" | ||
| 27 | |||
| 28 | help="$usage | ||
| 29 | or: $0 OPTION | ||
| 30 | If 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 | |||
| 35 | Report bugs to <bug-gnulib@gnu.org>." | ||
| 36 | |||
| 37 | version=`expr "$VERSION" : '\([^ ]*\)'` | ||
| 38 | version="move-if-change (gnulib) $version | ||
| 39 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
| 40 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | ||
| 41 | This is free software: you are free to change and redistribute it. | ||
| 42 | There is NO WARRANTY, to the extent permitted by law." | ||
| 43 | |||
| 44 | |||
| 45 | for arg | ||
| 46 | do | ||
| 47 | case $arg in | ||
| 48 | --help | --hel | --he | --h) | ||
| 49 | exec echo "$help" ;; | ||
| 50 | --version | --versio | --versi | --vers | --ver | --ve | --v) | ||
| 51 | exec echo "$version" ;; | ||
| 52 | --) | ||
| 53 | shift | ||
| 54 | break ;; | ||
| 55 | -*) | ||
| 56 | echo "$0: invalid option: $arg" >&2 | ||
| 57 | exit 1 ;; | ||
| 58 | *) | ||
| 59 | break ;; | ||
| 60 | esac | ||
| 61 | done | ||
| 62 | |||
| 63 | test $# = 2 || { echo "$0: $usage" >&2; exit 1; } | ||
| 64 | |||
| 65 | if test -r "$2" && cmp -s -- "$1" "$2"; then | ||
| 66 | rm -f -- "$1" | ||
| 10 | else | 67 | else |
| 11 | mv -f $1 $2 | 68 | mv -f -- "$1" "$2" |
| 12 | fi | ||
| 13 | else | ||
| 14 | mv -f $1 $2 | ||
| 15 | fi | 69 | fi |
| 70 | |||
| 71 | ## Local Variables: | ||
| 72 | ## eval: (add-hook 'write-file-hooks 'time-stamp) | ||
| 73 | ## time-stamp-start: "VERSION='" | ||
| 74 | ## time-stamp-format: "%:y-%02m-%02d %02H:%02M" | ||
| 75 | ## time-stamp-time-zone: "UTC" | ||
| 76 | ## time-stamp-end: "'; # UTC" | ||
| 77 | ## End: | ||