|
Packit |
6c4009 |
#!/bin/sh
|
|
Packit |
6c4009 |
# Like mv $1 $2, but if the files are the same, just delete $1.
|
|
Packit |
6c4009 |
# Status is zero if successful, nonzero otherwise.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
VERSION='2017-09-13 06:45'; # UTC
|
|
Packit |
6c4009 |
# The definition above must lie within the first 8 lines in order
|
|
Packit |
6c4009 |
# for the Emacs time-stamp write hook (at end) to update it.
|
|
Packit |
6c4009 |
# If you change this file with Emacs, please let the write hook
|
|
Packit |
6c4009 |
# do its job. Otherwise, update this string manually.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# This program is free software: you can redistribute it and/or modify
|
|
Packit |
6c4009 |
# it under the terms of the GNU General Public License as published by
|
|
Packit |
6c4009 |
# the Free Software Foundation, either version 3 of the License, or
|
|
Packit |
6c4009 |
# (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# This program is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
6c4009 |
# GNU General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# You should have received a copy of the GNU General Public License
|
|
Packit |
6c4009 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
usage="usage: $0 SOURCE DEST"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
help="$usage
|
|
Packit |
6c4009 |
or: $0 OPTION
|
|
Packit |
6c4009 |
If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
--help display this help and exit
|
|
Packit |
6c4009 |
--version output version information and exit
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The variable CMPPROG can be used to specify an alternative to 'cmp'.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Report bugs to <bug-gnulib@gnu.org>."
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
version=`expr "$VERSION" : '\([^ ]*\)'`
|
|
Packit |
6c4009 |
version="move-if-change (gnulib) $version
|
|
Packit |
6c4009 |
Copyright (C) 2011 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
|
|
Packit |
6c4009 |
This is free software: you are free to change and redistribute it.
|
|
Packit |
6c4009 |
There is NO WARRANTY, to the extent permitted by law."
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
cmpprog=${CMPPROG-cmp}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
for arg
|
|
Packit |
6c4009 |
do
|
|
Packit |
6c4009 |
case $arg in
|
|
Packit |
6c4009 |
--help | --hel | --he | --h)
|
|
Packit |
6c4009 |
exec echo "$help" ;;
|
|
Packit |
6c4009 |
--version | --versio | --versi | --vers | --ver | --ve | --v)
|
|
Packit |
6c4009 |
exec echo "$version" ;;
|
|
Packit |
6c4009 |
--)
|
|
Packit |
6c4009 |
shift
|
|
Packit |
6c4009 |
break ;;
|
|
Packit |
6c4009 |
-*)
|
|
Packit |
6c4009 |
echo "$0: invalid option: $arg" >&2
|
|
Packit |
6c4009 |
exit 1 ;;
|
|
Packit |
6c4009 |
*)
|
|
Packit |
6c4009 |
break ;;
|
|
Packit |
6c4009 |
esac
|
|
Packit |
6c4009 |
done
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; }
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then
|
|
Packit |
6c4009 |
rm -f -- "$1"
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
if mv -f -- "$1" "$2"; then :; else
|
|
Packit |
6c4009 |
# Ignore failure due to a concurrent move-if-change.
|
|
Packit |
6c4009 |
test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1"
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
fi
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
## Local Variables:
|
|
Packit |
6c4009 |
## eval: (add-hook 'write-file-hooks 'time-stamp)
|
|
Packit |
6c4009 |
## time-stamp-start: "VERSION='"
|
|
Packit |
6c4009 |
## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
|
|
Packit |
6c4009 |
## time-stamp-time-zone: "UTC0"
|
|
Packit |
6c4009 |
## time-stamp-end: "'; # UTC"
|
|
Packit |
6c4009 |
## End:
|