1*1debfc3dSmrg#!/bin/sh 2*1debfc3dSmrg# Like mv $1 $2, but if the files are the same, just delete $1. 3*1debfc3dSmrg# Status is zero if successful, nonzero otherwise. 4*1debfc3dSmrg 5*1debfc3dSmrgVERSION='2012-01-06 07:23'; # UTC 6*1debfc3dSmrg# The definition above must lie within the first 8 lines in order 7*1debfc3dSmrg# for the Emacs time-stamp write hook (at end) to update it. 8*1debfc3dSmrg# If you change this file with Emacs, please let the write hook 9*1debfc3dSmrg# do its job. Otherwise, update this string manually. 10*1debfc3dSmrg 11*1debfc3dSmrg# Copyright (C) 2002-2014 Free Software Foundation, Inc. 12*1debfc3dSmrg 13*1debfc3dSmrg# This program is free software: you can redistribute it and/or modify 14*1debfc3dSmrg# it under the terms of the GNU General Public License as published by 15*1debfc3dSmrg# the Free Software Foundation, either version 3 of the License, or 16*1debfc3dSmrg# (at your option) any later version. 17*1debfc3dSmrg 18*1debfc3dSmrg# This program is distributed in the hope that it will be useful, 19*1debfc3dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 20*1debfc3dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*1debfc3dSmrg# GNU General Public License for more details. 22*1debfc3dSmrg 23*1debfc3dSmrg# You should have received a copy of the GNU General Public License 24*1debfc3dSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 25*1debfc3dSmrg 26*1debfc3dSmrgusage="usage: $0 SOURCE DEST" 27*1debfc3dSmrg 28*1debfc3dSmrghelp="$usage 29*1debfc3dSmrg or: $0 OPTION 30*1debfc3dSmrgIf SOURCE is different than DEST, then move it to DEST; else remove SOURCE. 31*1debfc3dSmrg 32*1debfc3dSmrg --help display this help and exit 33*1debfc3dSmrg --version output version information and exit 34*1debfc3dSmrg 35*1debfc3dSmrgThe variable CMPPROG can be used to specify an alternative to 'cmp'. 36*1debfc3dSmrg 37*1debfc3dSmrgReport bugs to <bug-gnulib@gnu.org>." 38*1debfc3dSmrg 39*1debfc3dSmrgversion=`expr "$VERSION" : '\([^ ]*\)'` 40*1debfc3dSmrgversion="move-if-change (gnulib) $version 41*1debfc3dSmrgCopyright (C) 2011 Free Software Foundation, Inc. 42*1debfc3dSmrgLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 43*1debfc3dSmrgThis is free software: you are free to change and redistribute it. 44*1debfc3dSmrgThere is NO WARRANTY, to the extent permitted by law." 45*1debfc3dSmrg 46*1debfc3dSmrgcmpprog=${CMPPROG-cmp} 47*1debfc3dSmrg 48*1debfc3dSmrgfor arg 49*1debfc3dSmrgdo 50*1debfc3dSmrg case $arg in 51*1debfc3dSmrg --help | --hel | --he | --h) 52*1debfc3dSmrg exec echo "$help" ;; 53*1debfc3dSmrg --version | --versio | --versi | --vers | --ver | --ve | --v) 54*1debfc3dSmrg exec echo "$version" ;; 55*1debfc3dSmrg --) 56*1debfc3dSmrg shift 57*1debfc3dSmrg break ;; 58*1debfc3dSmrg -*) 59*1debfc3dSmrg echo "$0: invalid option: $arg" >&2 60*1debfc3dSmrg exit 1 ;; 61*1debfc3dSmrg *) 62*1debfc3dSmrg break ;; 63*1debfc3dSmrg esac 64*1debfc3dSmrgdone 65*1debfc3dSmrg 66*1debfc3dSmrgtest $# -eq 2 || { echo "$0: $usage" >&2; exit 1; } 67*1debfc3dSmrg 68*1debfc3dSmrgif test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then 69*1debfc3dSmrg rm -f -- "$1" 70*1debfc3dSmrgelse 71*1debfc3dSmrg if mv -f -- "$1" "$2"; then :; else 72*1debfc3dSmrg # Ignore failure due to a concurrent move-if-change. 73*1debfc3dSmrg test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1" 74*1debfc3dSmrg fi 75*1debfc3dSmrgfi 76*1debfc3dSmrg 77*1debfc3dSmrg## Local Variables: 78*1debfc3dSmrg## eval: (add-hook 'write-file-hooks 'time-stamp) 79*1debfc3dSmrg## time-stamp-start: "VERSION='" 80*1debfc3dSmrg## time-stamp-format: "%:y-%02m-%02d %02H:%02M" 81*1debfc3dSmrg## time-stamp-time-zone: "UTC" 82*1debfc3dSmrg## time-stamp-end: "'; # UTC" 83*1debfc3dSmrg## End: 84