diff --git a/misc/core.func b/misc/core.func index 17516f63..086a105e 100644 --- a/misc/core.func +++ b/misc/core.func @@ -198,8 +198,7 @@ silent() { local rc=$? set -Eeuo pipefail if [[ $rc -ne 0 ]]; then - BASH_COMMAND="$cmd" - error_handler "$rc" + error_handler "$rc" "$cmd" fi return $rc } diff --git a/misc/error_handler.func b/misc/error_handler.func index 7d78fab4..2e47ece0 100644 --- a/misc/error_handler.func +++ b/misc/error_handler.func @@ -82,10 +82,9 @@ explain_exit_code() { # === Error handler ============================================================ error_handler() { local exit_code=${1:-$?} + local command=${2:-${BASH_COMMAND:-unknown}} local line_number=${BASH_LINENO[0]:-unknown} - local command=${BASH_COMMAND:-unknown} - # $STD removal to show the actual failing command command="${command//\$STD/}" if [[ "$exit_code" -eq 0 ]]; then