From 9e94c2400774dd498c5798c56860147f4001b419 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Thu, 2 Feb 2017 18:36:20 -0600 Subject: [PATCH] use traps --- bin/snap-sync | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/snap-sync b/bin/snap-sync index 7b2ce2c..8120e71 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -10,17 +10,25 @@ version="0.3" name="snap-sync" -set -e - function error_exit { for u in $(users); do notify_cmd="sudo -u $u DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus notify-send" $notify_cmd -a $name 'Error' 'Check journal for more information.' --icon=dialog-error done + printf "\nExited due to error.\n" | tee $PIPE exit 1 } +function kill_exit +{ + printf "\nExited due to user intervention.\n" | tee $PIPE + exit 1 +} + +trap error_exit ERR +trap kill_exit SIGTERM SIGINT + while [[ $# -gt 0 ]]; do key="$1" case $key in