summaryrefslogtreecommitdiff
path: root/write-ifchanged
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-04-08 17:00:05 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-04-08 17:00:05 -0400
commit41bfc4bb5e1042ec9eca48ed645393b12978d703 (patch)
tree094cf68df41f7f5c98a1c844e51bc32fb0e7155d /write-ifchanged
parent608f4f254ccf95a01b5480e2dbe7a1b6e54c8609 (diff)
Actual install process
Diffstat (limited to 'write-ifchanged')
-rwxr-xr-xwrite-ifchanged11
1 files changed, 11 insertions, 0 deletions
diff --git a/write-ifchanged b/write-ifchanged
new file mode 100755
index 0000000..c65fa16
--- /dev/null
+++ b/write-ifchanged
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+outfile=$1
+tmpfile="$(dirname "$outfile")/.tmp${outfile##*/}"
+
+cat > "$tmpfile" || exit $?
+if cmp -s "$tmpfile" "$outfile"; then
+ rm -f "$tmpfile" || :
+else
+ mv -f "$tmpfile" "$outfile"
+fi