From 869369730a7757e34fdf45905cf97fa04ba2172b Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Tue, 7 Jul 2020 17:19:31 -0500 Subject: [PATCH] Trap a couple of signals in ssam in order to guarantee the temporary file is removed. --- ssam | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ssam b/ssam index c7fb999..5094340 100755 --- a/ssam +++ b/ssam @@ -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 ',{' @@ -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" \ No newline at end of file +exit $? \ No newline at end of file