]>
Commit | Line | Data |
---|---|---|
01cc0be6 RM |
1 | #!/bin/sh |
2 | # Like mv $1 $2, but if the files are the same, just delete $1. | |
9e54314b JM |
3 | # Status is zero if successful, nonzero otherwise. |
4 | ||
c37cd439 | 5 | VERSION='2018-03-07 03:47'; # UTC |
9e54314b JM |
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. | |
10 | ||
0933a4a1 | 11 | # Copyright (C) 2002-2022 Free Software Foundation, Inc. |
9e54314b JM |
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 | |
41d11b15 | 24 | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
9e54314b JM |
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 | The variable CMPPROG can be used to specify an alternative to 'cmp'. | |
36 | ||
37 | Report bugs to <bug-gnulib@gnu.org>." | |
38 | ||
ba741225 | 39 | year=`expr "$VERSION" : '\([^-]*\)'` |
9e54314b JM |
40 | version=`expr "$VERSION" : '\([^ ]*\)'` |
41 | version="move-if-change (gnulib) $version | |
ba741225 | 42 | Copyright $year Free Software Foundation, Inc. |
41d11b15 | 43 | License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> |
9e54314b JM |
44 | This is free software: you are free to change and redistribute it. |
45 | There is NO WARRANTY, to the extent permitted by law." | |
46 | ||
47 | cmpprog=${CMPPROG-cmp} | |
48 | ||
49 | for arg | |
50 | do | |
51 | case $arg in | |
52 | --help | --hel | --he | --h) | |
53 | exec echo "$help" ;; | |
54 | --version | --versio | --versi | --vers | --ver | --ve | --v) | |
55 | exec echo "$version" ;; | |
56 | --) | |
57 | shift | |
58 | break ;; | |
59 | -*) | |
60 | echo "$0: invalid option: $arg" >&2 | |
61 | exit 1 ;; | |
62 | *) | |
63 | break ;; | |
64 | esac | |
65 | done | |
66 | ||
67 | test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; } | |
68 | ||
69 | if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then | |
70 | rm -f -- "$1" | |
01cc0be6 | 71 | else |
9e54314b JM |
72 | if mv -f -- "$1" "$2"; then :; else |
73 | # Ignore failure due to a concurrent move-if-change. | |
74 | test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1" | |
75 | fi | |
01cc0be6 | 76 | fi |
9e54314b JM |
77 | |
78 | ## Local Variables: | |
c37cd439 | 79 | ## eval: (add-hook 'before-save-hook 'time-stamp) |
9e54314b JM |
80 | ## time-stamp-start: "VERSION='" |
81 | ## time-stamp-format: "%:y-%02m-%02d %02H:%02M" | |
7f7dd1d3 | 82 | ## time-stamp-time-zone: "UTC0" |
9e54314b JM |
83 | ## time-stamp-end: "'; # UTC" |
84 | ## End: |