From 41e59015a2e61ee42db6d8494629ea902bc42be3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 12 May 2013 01:32:14 -0400 Subject: jh-checksource: remove temp files even for abnormal termination --- jh-checksource.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jh-checksource.sh b/jh-checksource.sh index 9e3a9d6..7ebb04e 100644 --- a/jh-checksource.sh +++ b/jh-checksource.sh @@ -58,6 +58,8 @@ main() { # Init unsafe_files="$(mktemp)" + cleanup() { rm -f -- "$unsafe_files"; } + trap cleanup EXIT # Heavy lifting find . -type f -printf '%s %h/%f\n' | # find all files @@ -82,10 +84,7 @@ main() { if [[ -n "$(cat "$unsafe_files")" ]]; then <"$unsafe_files" sort | print-$format - rm -f "$unsafe_files" exit 1 - else - rm -f "$unsafe_files" fi } -- cgit v1.2.3-54-g00ecf