test
This commit is contained in:
parent
983ea68da6
commit
773ae42241
@ -193,26 +193,20 @@ SILENT_LOGFILE="/tmp/silent.$$.log"
|
|||||||
|
|
||||||
silent() {
|
silent() {
|
||||||
local cmd="$*"
|
local cmd="$*"
|
||||||
|
local caller_line="${BASH_LINENO[0]:-unknown}" # Capture the line where silent was called
|
||||||
|
|
||||||
set +Eeuo pipefail
|
set +Eeuo pipefail
|
||||||
"$@" >>"$SILENT_LOGFILE" 2>&1
|
"$@" >>"$SILENT_LOGFILE" 2>&1
|
||||||
local rc=$?
|
local rc=$?
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
if [[ $rc -ne 0 ]]; then
|
if [[ $rc -ne 0 ]]; then
|
||||||
local explanation
|
# Call error_handler with proper line number context
|
||||||
explanation="$(explain_exit_code "$rc")"
|
BASH_LINENO[0]=$caller_line # Set the line number for error_handler
|
||||||
|
error_handler "$rc" "$cmd"
|
||||||
printf "\e[?25h"
|
|
||||||
echo -e "\n${RD}[ERROR]${CL}: exit code ${RD}${rc}${CL} (${explanation}): while executing command ${YW}${cmd}${CL}\n"
|
|
||||||
|
|
||||||
if [[ -s "$SILENT_LOGFILE" ]]; then
|
|
||||||
echo "--- Last 20 lines of silent log ($SILENT_LOGFILE) ---"
|
|
||||||
tail -n 20 "$SILENT_LOGFILE"
|
|
||||||
echo "---------------------------------------------------"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit "$rc"
|
return $rc
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the shell is using bash
|
# Check if the shell is using bash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user