From e5c5df601312d4674fd3ef070edc713274b7263d Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Wed, 3 Dec 2025 13:08:35 +0900 Subject: [PATCH] Fix error trap with return error to STD ERR --- borg.backup.functions.init.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/borg.backup.functions.init.sh b/borg.backup.functions.init.sh index cf357fa..407a0d6 100644 --- a/borg.backup.functions.init.sh +++ b/borg.backup.functions.init.sh @@ -6,10 +6,10 @@ if [ -z "${MODULE}" ]; then fi; set -ETu #-e -o pipefail -trap error_trap ERR -trap cleanup SIGINT SIGTERM +trap _catch ERR +trap _cleanup SIGINT SIGTERM -cleanup() { +_cleanup() { # script cleanup here echo "Script abort: $? @LINE: $(caller)"; # unset exported vars @@ -17,8 +17,8 @@ cleanup() { # end trap trap - SIGINT SIGTERM } -error_trap() { - echo "Some part of the script failed with an error: $? @COMMAND: '$BASH_COMMAND' @LINE: $(caller)"; +_catch() { + echo "Some part of the script failed with ERROR: $? @COMMAND: '$BASH_COMMAND' @LINE: $(caller)" >&2; # exit caller so we do not catch the same error again exit 0; }