From 5c8ab2c259e8439a6713645bd3939a30ea63cf21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Wed, 20 Sep 2023 14:24:04 +0200 Subject: sponge_only_on_success.sh --- skripti/sponge_only_on_success.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 skripti/sponge_only_on_success.sh (limited to 'skripti') 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 -- cgit v1.2.3