From 3696cc06af7488b1f2c1675f146168738ecdd2ac Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sat, 8 Feb 2025 13:21:31 +0800 Subject: [PATCH] new traps example --- helpers/traps.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 helpers/traps.sh diff --git a/helpers/traps.sh b/helpers/traps.sh new file mode 100644 index 0000000..f96de90 --- /dev/null +++ b/helpers/traps.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +#TODO source basic.sh +#TODO source args-parser/args.sh + +######################################################## +# Trap usage examples +######################################################## + +# for sig in SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGTERM SIGTSTP; do +# # shellcheck disable=SC2064 +# trap "set +x && echo && echo && echo '*** Прервано сигналом $sig, остановка ***' && exit" $sig +# done + +for sig in SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGTERM SIGTSTP; do + trap "myfunc" $sig +done + +myfunc() { + echo "trapped!" + exit +}