X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=build-aux%2Fmove-if-change;h=f45cbea3bf7fb0ee54e58f367aceccadf5c2510a;hb=43593319b31e6b0175b8eec4433bac744959822d;hp=a891ca51f0cd90ee33abea813faf4ab2f808075e;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/build-aux/move-if-change b/build-aux/move-if-change index a891ca51f..f45cbea3b 100755 --- a/build-aux/move-if-change +++ b/build-aux/move-if-change @@ -2,13 +2,13 @@ # Like mv $1 $2, but if the files are the same, just delete $1. # Status is zero if successful, nonzero otherwise. -VERSION='2007-09-28 23:10'; # UTC +VERSION='2012-01-06 07:23'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. -# Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. +# Copyright (C) 2002-2013 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,15 +32,18 @@ If SOURCE is different than DEST, then move it to DEST; else remove SOURCE. --help display this help and exit --version output version information and exit +The variable CMPPROG can be used to specify an alternative to 'cmp'. + Report bugs to ." version=`expr "$VERSION" : '\([^ ]*\)'` version="move-if-change (gnulib) $version -Copyright (C) 2007 Free Software Foundation, Inc. +Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law." +cmpprog=${CMPPROG-cmp} for arg do @@ -60,12 +63,15 @@ do esac done -test $# = 2 || { echo "$0: $usage" >&2; exit 1; } +test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; } -if test -r "$2" && cmp -s -- "$1" "$2"; then +if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then rm -f -- "$1" else - mv -f -- "$1" "$2" + if mv -f -- "$1" "$2"; then :; else + # Ignore failure due to a concurrent move-if-change. + test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1" + fi fi ## Local Variables: