Skip to content

Commit

Permalink
Trap a couple of signals in ssam in order to guarantee the temporary …
Browse files Browse the repository at this point in the history
…file is removed.
  • Loading branch information
arizvisa committed Jul 7, 2020
1 parent 1dcf1de commit 8693697
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ssam
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ if [ -z "$TMPDIR" ]; then
fi
tmp="$TMPDIR/ssam.tmp.$USER.$$"

cat "$@" >$tmp
trap 'result=$?; rm -f "$tmp"; exit $result' INT EXIT KILL
cat "$@" >"$tmp"

input()
{
# select entire file
echo ',{'
Expand All @@ -57,8 +57,6 @@ input()
[ ! -z "$flagf" ] && cat "$flagf"
[ ! -z "$flage" ] && echo "$flage"
[ "$flagn" -eq 0 ] && echo ','
}

input | sam -d "$tmp" 2>/dev/null
} | sam -d "$tmp" 2>/dev/null

rm -f "$tmp"
exit $?

0 comments on commit 8693697

Please sign in to comment.