summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-13 21:23:54 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-13 21:23:54 -0500
commit1e0c5f3edfd1c5c59563b31dfc7e0e395fef53ca (patch)
treee496ea616da56836cce004b8cbb66257e5fe062b /bin
parent8fc346426bad64035330c8b394b8a515beb8d9d5 (diff)
Fix
Diffstat (limited to 'bin')
-rwxr-xr-xbin/post-commit.githook2
-rwxr-xr-xbin/write-atomic21
2 files changed, 22 insertions, 1 deletions
diff --git a/bin/post-commit.githook b/bin/post-commit.githook
index 3f576e6..997afa3 100755
--- a/bin/post-commit.githook
+++ b/bin/post-commit.githook
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -e
-d="$(dirname -- "$0")"
+d="$(dirname -- "$(readlink -f -- "$0")")"
"$d"/auto-changelog
"$d"/pre-generate &>/dev/tty &
diff --git a/bin/write-atomic b/bin/write-atomic
new file mode 100755
index 0000000..efb2551
--- /dev/null
+++ b/bin/write-atomic
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Copyright (C) 2015-2016 Luke Shumaker
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+outfile=$1
+tmpfile="$(dirname "$outfile")/.tmp${outfile##*/}"
+
+cat > "$tmpfile" || { r=$?; rm -f "$tmpfile"; exit $r; }
+mv -f "$tmpfile" "$outfile"