summaryrefslogtreecommitdiffstats
path: root/skripti
diff options
context:
space:
mode:
Diffstat (limited to 'skripti')
-rwxr-xr-xskripti/sponge_only_on_success.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/skripti/sponge_only_on_success.sh b/skripti/sponge_only_on_success.sh
new file mode 100755
index 0000000..6f6f65b
--- /dev/null
+++ b/skripti/sponge_only_on_success.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+p=`rev <<<$0 | cut -d/ -f1 | rev`
+t=`mktemp -p "" $p.XXX`
+o=$1
+shift
+$@ > $t
+r=$?
+if [ $r -eq 0 ]
+then
+cat $t > $o
+else
+echo called command $@ exited with nonzero $r >&2
+exit $r
+fi