summaryrefslogtreecommitdiff
path: root/lib/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common.sh')
-rw-r--r--lib/common.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/common.sh b/lib/common.sh
index 5c144e2..74b251f 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -62,8 +62,6 @@ setup_workdir() {
}
cleanup() {
- trap - EXIT INT QUIT TERM HUP
-
[[ -n $WORKDIR ]] && rm -rf "$WORKDIR"
[[ $1 ]] && exit $1
}
@@ -73,13 +71,23 @@ abort() {
cleanup 0
}
+trap_abort() {
+ trap - EXIT INT QUIT TERM HUP
+ abort
+}
+
+trap_exit() {
+ trap - EXIT INT QUIT TERM HUP
+ cleanup 0
+}
+
die() {
error "$*"
cleanup 1
}
-trap abort INT QUIT TERM HUP
-trap 'cleanup 0' EXIT
+trap 'trap_abort' INT QUIT TERM HUP
+trap 'trap_exit' EXIT
##
# usage : in_array( $needle, $haystack )