12a6b7db3Sskrll#!/bin/sh 22a6b7db3Sskrll# Like mv $1 $2, but if the files are the same, just delete $1. 32a6b7db3Sskrll# Status is zero if successful, nonzero otherwise. 42a6b7db3Sskrll 5*9573673dSchristosVERSION='2012-01-06 07:23'; # UTC 6883529b6Schristos# The definition above must lie within the first 8 lines in order 7883529b6Schristos# for the Emacs time-stamp write hook (at end) to update it. 8883529b6Schristos# If you change this file with Emacs, please let the write hook 9883529b6Schristos# do its job. Otherwise, update this string manually. 102a6b7db3Sskrll 11*9573673dSchristos# Copyright (C) 2002-2014 Free Software Foundation, Inc. 122a6b7db3Sskrll 13883529b6Schristos# This program is free software: you can redistribute it and/or modify 14883529b6Schristos# it under the terms of the GNU General Public License as published by 15883529b6Schristos# the Free Software Foundation, either version 3 of the License, or 16883529b6Schristos# (at your option) any later version. 17883529b6Schristos 18883529b6Schristos# This program is distributed in the hope that it will be useful, 19883529b6Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 20883529b6Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21883529b6Schristos# GNU General Public License for more details. 22883529b6Schristos 23883529b6Schristos# You should have received a copy of the GNU General Public License 24883529b6Schristos# along with this program. If not, see <http://www.gnu.org/licenses/>. 25883529b6Schristos 26883529b6Schristosusage="usage: $0 SOURCE DEST" 27883529b6Schristos 28883529b6Schristoshelp="$usage 29883529b6Schristos or: $0 OPTION 30883529b6SchristosIf SOURCE is different than DEST, then move it to DEST; else remove SOURCE. 31883529b6Schristos 32883529b6Schristos --help display this help and exit 33883529b6Schristos --version output version information and exit 34883529b6Schristos 35*9573673dSchristosThe variable CMPPROG can be used to specify an alternative to 'cmp'. 36883529b6Schristos 37883529b6SchristosReport bugs to <bug-gnulib@gnu.org>." 38883529b6Schristos 39883529b6Schristosversion=`expr "$VERSION" : '\([^ ]*\)'` 40883529b6Schristosversion="move-if-change (gnulib) $version 41883529b6SchristosCopyright (C) 2011 Free Software Foundation, Inc. 42883529b6SchristosLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 43883529b6SchristosThis is free software: you are free to change and redistribute it. 44883529b6SchristosThere is NO WARRANTY, to the extent permitted by law." 45883529b6Schristos 46883529b6Schristoscmpprog=${CMPPROG-cmp} 47883529b6Schristos 48883529b6Schristosfor arg 49883529b6Schristosdo 502a6b7db3Sskrll case $arg in 51883529b6Schristos --help | --hel | --he | --h) 52883529b6Schristos exec echo "$help" ;; 53883529b6Schristos --version | --versio | --versi | --vers | --ver | --ve | --v) 54883529b6Schristos exec echo "$version" ;; 55883529b6Schristos --) 56883529b6Schristos shift 57883529b6Schristos break ;; 58883529b6Schristos -*) 59883529b6Schristos echo "$0: invalid option: $arg" >&2 60883529b6Schristos exit 1 ;; 61883529b6Schristos *) 62883529b6Schristos break ;; 632a6b7db3Sskrll esac 642a6b7db3Sskrlldone 652a6b7db3Sskrll 66883529b6Schristostest $# -eq 2 || { echo "$0: $usage" >&2; exit 1; } 67883529b6Schristos 68883529b6Schristosif test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then 69883529b6Schristos rm -f -- "$1" 702a6b7db3Sskrllelse 71883529b6Schristos if mv -f -- "$1" "$2"; then :; else 72883529b6Schristos # Ignore failure due to a concurrent move-if-change. 73883529b6Schristos test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1" 742a6b7db3Sskrll fi 75883529b6Schristosfi 76883529b6Schristos 77883529b6Schristos## Local Variables: 78883529b6Schristos## eval: (add-hook 'write-file-hooks 'time-stamp) 79883529b6Schristos## time-stamp-start: "VERSION='" 80883529b6Schristos## time-stamp-format: "%:y-%02m-%02d %02H:%02M" 81883529b6Schristos## time-stamp-time-zone: "UTC" 82883529b6Schristos## time-stamp-end: "'; # UTC" 83883529b6Schristos## End: 84