summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-12 01:32:14 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-12 01:32:14 -0400
commit41e59015a2e61ee42db6d8494629ea902bc42be3 (patch)
tree7559e23b4cbf3921cdbc11e92efc3132804dea70
parent952f2444763af9100339876b1bfc88c169346967 (diff)
jh-checksource: remove temp files even for abnormal termination
-rw-r--r--jh-checksource.sh5
1 files 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
}