From ba51df5bb1225d5076732bbc4eb4e57efdb7f39b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 16 Sep 2025 10:41:55 +0200 Subject: [PATCH] testing --- misc/core.func | 10 +++++++--- misc/error_handler.func | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/misc/core.func b/misc/core.func index 086a105e..011864a1 100644 --- a/misc/core.func +++ b/misc/core.func @@ -193,13 +193,17 @@ SILENT_LOGFILE="/tmp/silent.$$.log" silent() { local cmd="$*" - set +Eeuo pipefail + + trap - ERR "$@" >>"$SILENT_LOGFILE" 2>&1 local rc=$? - set -Eeuo pipefail + trap 'error_handler' ERR + if [[ $rc -ne 0 ]]; then - error_handler "$rc" "$cmd" + BASH_COMMAND="$cmd" + error_handler "$rc" fi + return $rc } diff --git a/misc/error_handler.func b/misc/error_handler.func index 2e47ece0..fc39f6a4 100644 --- a/misc/error_handler.func +++ b/misc/error_handler.func @@ -85,6 +85,7 @@ error_handler() { local command=${2:-${BASH_COMMAND:-unknown}} local line_number=${BASH_LINENO[0]:-unknown} + # clean up cosmetic STD variable command="${command//\$STD/}" if [[ "$exit_code" -eq 0 ]]; then @@ -95,7 +96,7 @@ error_handler() { explanation="$(explain_exit_code "$exit_code")" printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL} (${explanation}): while executing command ${YWB}${command}${CL}\n" + echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL} (${explanation}): while executing command ${YW}${command}${CL}\n" if [[ -n "${DEBUG_LOGFILE:-}" ]]; then { @@ -108,7 +109,6 @@ error_handler() { } >>"$DEBUG_LOGFILE" fi - # Silent-Log if [[ -n "${SILENT_LOGFILE:-}" && -s "$SILENT_LOGFILE" ]]; then echo "--- Last 20 lines of silent log ($SILENT_LOGFILE) ---" tail -n 20 "$SILENT_LOGFILE"