summaryrefslogtreecommitdiff
path: root/src/config/move-if-changed
diff options
context:
space:
mode:
Diffstat (limited to 'src/config/move-if-changed')
-rwxr-xr-xsrc/config/move-if-changed17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/config/move-if-changed b/src/config/move-if-changed
new file mode 100755
index 0000000000000..21403e129a935
--- /dev/null
+++ b/src/config/move-if-changed
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Move file 1 to file 2 if they don't already match.
+# Good for "make depend" for example, where it'd be nice to keep the
+# old datestamp.
+if [ $# != 2 ]; then
+ echo 2>&1 usage: $0 newfile oldfilename
+ exit 1
+fi
+#
+if [ ! -r "$2" ]; then
+ exec mv -f "$1" "$2"
+fi
+if cmp "$1" "$2" >/dev/null; then
+ echo "$2 is unchanged"
+ exec rm -f "$1"
+fi
+exec mv -f "$1" "$2"