aboutsummaryrefslogtreecommitdiff
path: root/config/move-if-change
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
committerdos-reis <gdr@axiomatics.org>2007-08-14 05:14:52 +0000
commitab8cc85adde879fb963c94d15675783f2cf4b183 (patch)
treec202482327f474583b750b2c45dedfc4e4312b1d /config/move-if-change
downloadopen-axiom-ab8cc85adde879fb963c94d15675783f2cf4b183.tar.gz
Initial population.
Diffstat (limited to 'config/move-if-change')
-rwxr-xr-xconfig/move-if-change22
1 files changed, 22 insertions, 0 deletions
diff --git a/config/move-if-change b/config/move-if-change
new file mode 100755
index 00000000..ff74a556
--- /dev/null
+++ b/config/move-if-change
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Like mv $1 $2, but if the files are the same, just delete $1.
+# Status is zero if successful, nonzero otherwise.
+
+usage="$0: usage: $0 SOURCE DEST"
+
+case $# in
+2) ;;
+*) echo "$usage" >&2; exit 1;;
+esac
+
+for arg in "$1" "$2"; do
+ case $arg in
+ -*) echo "$usage" >&2; exit 1;;
+ esac
+done
+
+if test -r "$2" && cmp -s "$1" "$2"; then
+ rm -f "$1"
+else
+ mv -f "$1" "$2"
+fi