From 3a0423ad49019e9a562ce99187bfffcc4ec3fbda Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 26 Mar 2020 02:43:00 -0600 Subject: [PATCH] add trap handling --- borghelper.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/borghelper.sh b/borghelper.sh index c5a6ce6..a03993f 100644 --- a/borghelper.sh +++ b/borghelper.sh @@ -4,6 +4,8 @@ ## borg helper script for viewing and restoring backups # +### trap +trap trapExit 1 2 3 6 ### functions consoleError() { @@ -16,6 +18,11 @@ textblock() { printf "%s\n" "$1" | fold -w "$width" -s } +trapExit () { + printf "%s\nScript execution terminated via signal.\n\n%s" "$err" "$norm" + exit 99 +} + ### text formatting presets err=$(tput bold)$(tput setaf 1)