summaryrefslogtreecommitdiff
path: root/write-ifchanged
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-17 18:49:42 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-17 18:49:42 -0400
commitc9cfc9bc4451a6219f71407b9a6e00b51defc713 (patch)
treeeee260ac1b6ff37b5fba45b89204864d810dfe67 /write-ifchanged
parent733636464ea990d96d38edefff9ca326e8195cf4 (diff)
Use automake.mk
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