summaryrefslogblamecommitdiffstats
path: root/skripti/sponge_only_on_success.sh
blob: 8b3ed309daf22979265cdd25c988ff42e635cf20 (plain) (tree)
1
2
3
4


                                 
                 










                                                 
#!/bin/bash
p=`rev <<<$0 | cut -d/ -f1 | rev`
t=`mktemp -p "" $p.XXX`
trap "rm $t" EXIT
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