summaryrefslogtreecommitdiff
path: root/write-ifchanged
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-02-08 16:36:45 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-02-08 16:36:45 -0500
commit7e704d7ac997387341e920e1757c24cac0efe5e9 (patch)
treea9f30eabaaad5496397a91053d3e03bab1ea57e4 /write-ifchanged
parent7785a72495e3eb0ea826b41720c241f58a15b601 (diff)
Refactor the build system. Avoid recursive make.
This looks like a lot, but more things should "just work". We have `make dist` now!
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