mv replacement to only move if target differs from source.
authordrepper <drepper>
Fri, 8 May 1998 20:55:22 +0000 (20:55 +0000)
committerdrepper <drepper>
Fri, 8 May 1998 20:55:22 +0000 (20:55 +0000)
scripts/move-if-change [new file with mode: 0755]

diff --git a/scripts/move-if-change b/scripts/move-if-change
new file mode 100755 (executable)
index 0000000..66d8b8a
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Like mv $1 $2, but if the files are the same, just delete $1.
+# Status is 0 if $2 is changed, 1 otherwise.
+if
+test -r $2
+then
+if
+cmp -s $1 $2
+then
+echo $2 is unchanged
+rm -f $1
+else
+mv -f $1 $2
+fi
+else
+mv -f $1 $2
+fi