Fix the error trap with exit to stop calling it again with itself

This commit is contained in:
Clemens Schwaighofer
2025-12-03 13:03:46 +09:00
parent 8a8de773df
commit 9e0db8bae9
2 changed files with 5 additions and 4 deletions

View File

@@ -18,8 +18,9 @@ cleanup() {
trap - SIGINT SIGTERM
}
error_trap() {
echo "Some part of the script failed with an error: $? @LINE: $(caller)";
trap - ERR
echo "Some part of the script failed with an error: $? @COMMAND: '$BASH_COMMAND' @LINE: $(caller)";
# exit caller so we do not catch the same error again
exit 0;
}
# on exit unset any exported var
trap "unset BORG_BASE_DIR BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK BORG_RELOCATED_REPO_ACCESS_IS_OK" EXIT;

View File

@@ -296,10 +296,10 @@ if [ "${VERIFY}" -eq 1 ] || [ "${INIT}" -eq 1 ]; then
printf "${PRINTF_SUB_BLOCK}" "VERIFY" "$(date +'%F %T')" "${MODULE}";
if [ -n "${TARGET_SERVER}" ]; then
if [ "${DEBUG}" -eq 1 ]; then
echo "${BORG_COMMAND} info ${OPT_REMOTE} ${REPOSITORY}";
echo "${BORG_COMMAND} info ${OPT_REMOTE} ${REPOSITORY} 2>&1 ";
fi;
# use borg info and verify if it returns "Repository ID:" in the first line
REPO_VERIFY=$(${BORG_COMMAND} info ${OPT_REMOTE} "${REPOSITORY}");
REPO_VERIFY=$(${BORG_COMMAND} info ${OPT_REMOTE} "${REPOSITORY}" 2>&1);
__LAST_ERROR=$?
if [ $__LAST_ERROR -ne 0 ]; then
echo "[!] Repository verify error: ${REPO_VERIFY}";