add trap handling

This commit is contained in:
Asif Bacchus 2020-03-26 02:43:00 -06:00
parent 7838b0c6e0
commit 3a0423ad49
1 changed files with 7 additions and 0 deletions

View File

@ -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)