summaryrefslogtreecommitdiffstats
path: root/build-aux/move-if-change
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-06 15:45:49 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-06 16:38:27 +0100
commit2fc5b35b79299e3ebd61b2d335ea8f4785473823 (patch)
treefacd6e60dce31753b317aa10ba696f82b6748b7e /build-aux/move-if-change
parent36b14c8448e46e93cad7067d4249f2f005a7f6c7 (diff)
downloadmsitools-2fc5b35b79299e3ebd61b2d335ea8f4785473823.tar.gz
msitools-2fc5b35b79299e3ebd61b2d335ea8f4785473823.tar.xz
msitools-2fc5b35b79299e3ebd61b2d335ea8f4785473823.zip
test: add autotest infrastructure
Diffstat (limited to 'build-aux/move-if-change')
-rwxr-xr-xbuild-aux/move-if-change17
1 files changed, 17 insertions, 0 deletions
diff --git a/build-aux/move-if-change b/build-aux/move-if-change
new file mode 100755
index 0000000..03dd02e
--- /dev/null
+++ b/build-aux/move-if-change
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Like mv $1 $2, but if the files are the same, just delete $1.
+# Status is zero if successful, nonzero otherwise.
+#
+# Copyright (C) 2011 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law."
+
+if test -r "$2" && cmp -- "$1" "$2" >/dev/null; then
+ rm -f -- "$1"
+else
+ if mv -f -- "$1" "$2"; then :; else
+ # Ignore failure due to a concurrent move-if-change.
+ test -r "$2" && cmp -- "$1" "$2" >/dev/null && rm -f -- "$1"
+ fi
+fi