aboutsummaryrefslogtreecommitdiff
path: root/utils/cleaner
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-20 21:19:05 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-20 21:22:36 +0200
commitf287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 (patch)
tree5025b33a8c3d4c69ad2b62e1169b669c56f712f9 /utils/cleaner
parent65f52ead41dc6df73671ddd3a8c6a2edecb6dfb3 (diff)
downloadmulticonfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.gz
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.bz2
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.zip
Commit current statecomplicated
Diffstat (limited to 'utils/cleaner')
-rw-r--r--utils/cleaner23
1 files changed, 23 insertions, 0 deletions
diff --git a/utils/cleaner b/utils/cleaner
new file mode 100644
index 0000000..4919085
--- /dev/null
+++ b/utils/cleaner
@@ -0,0 +1,23 @@
+# vim:ft=sh:noexpandtab
+# Functions for cleanups
+
+EXIT_CODE=0
+
+do_cleanup() {
+ echo "$CLEANUP_ACTIONS" | while read CMD; do
+ eval "$CMD"
+ done
+ exit $EXIT_CODE
+}
+
+trap do_cleanup EXIT INT QUIT TERM ABRT
+
+cleaner_add() {
+ CLEANUP_ACTIONS="$CLEANUP_ACTIONS
+$@"
+}
+
+cleaner_rm() {
+ # TODO this might be problematic with special characters
+ CLEANUP_ACTIONS="$(echo "$CLEANUP_ACTIONS" | sed "/^$@$/d")"
+}