test
This commit is contained in:
parent
983ea68da6
commit
773ae42241
@ -193,26 +193,20 @@ SILENT_LOGFILE="/tmp/silent.$$.log"
|
||||
|
||||
silent() {
|
||||
local cmd="$*"
|
||||
local caller_line="${BASH_LINENO[0]:-unknown}" # Capture the line where silent was called
|
||||
|
||||
set +Eeuo pipefail
|
||||
"$@" >>"$SILENT_LOGFILE" 2>&1
|
||||
local rc=$?
|
||||
set -Eeuo pipefail
|
||||
|
||||
if [[ $rc -ne 0 ]]; then
|
||||
local explanation
|
||||
explanation="$(explain_exit_code "$rc")"
|
||||
|
||||
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
|
||||
|
||||
exit "$rc"
|
||||
# Call error_handler with proper line number context
|
||||
BASH_LINENO[0]=$caller_line # Set the line number for error_handler
|
||||
error_handler "$rc" "$cmd"
|
||||
fi
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
# Check if the shell is using bash
|
||||
|
Loading…
x
Reference in New Issue
Block a user