Browse Source

small miaou_debug changes

main
pvincent 2 weeks ago
parent
commit
3f50122ecc
  1. 13
      poc

13
poc

@ -202,8 +202,8 @@ function on_pipe {
unset 'error_source[-1]' 'error_lineno[-1]' 'error_funcname[-1]'
load_tmp_error
last_error="${tmp_error[-1]}"
regex='^(.*): line ([0-9]+): miaou_error: SUBSHELL_ERROR ([0-9]+) payload: (.*)$'
if [[ $last_error =~ $regex ]]; then
source=${BASH_REMATCH[1]}
@ -211,6 +211,7 @@ function on_pipe {
failure_code=${BASH_REMATCH[3]}
failure_payload=${BASH_REMATCH[4]}
failure_type="SUBSHELL_ERROR"
miaou_debug "<subshell_error payload={${failure_payload}}"
error_source=("$source" "${error_source[@]}")
error_lineno=("$lineno" "${error_lineno[@]}")
error_funcname=("${error_funcname[@]}" '<main>')
@ -218,7 +219,7 @@ function on_pipe {
failure_code=141
failure_type="PIPE_ERROR"
fi
miaou_debug "</on_pipe/>"
miaou_debug "</on_pipe>"
builtin exit "$failure_code"
}
@ -340,7 +341,7 @@ function on_exit {
unset 'tmp_error[-1]'
add_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" "${failure_payload}"
miaou_debug "<unbound_variable source=${source} line=${line} payload={${failure_payload}}/>"
miaou_debug "<unbound_variable source=${source} line=${line} payload=${failure_payload}/>"
else
failure_type='UNKNOWN ERROR'
fi
@ -354,7 +355,7 @@ function on_exit {
2>&3 >&4 dump_stacktrace
fi
if [[ $code -gt 0 ]]; then
miaou_debug "</on_exit exit=$code>"
miaou_debug "</on_exit failure>"
else
miaou_debug "</on_exit success>"
fi
@ -374,11 +375,9 @@ trap 'on_exit $?' EXIT
trap 'on_pipe' PIPE
trap 'on_return' RETURN
declare -a tmp_error # to prevent loading multiple times
if [[ -e /proc/$$/fd/3 ]]; then exec 4>&3 3>&-; else exec 4>/dev/tty; fi # swap fd 3 4 when fd 3 sent off
exec 3>/dev/stderr 2>"$MIAOU_BASH_ERROR"
miaou_debug "<source from=$BASH_ARGV0 pid=${BASHPID}/>"
miaou_debug "<source file=$BASH_ARGV0 pid=${BASHPID}/>"
# shellcheck source=/dev/null
source "$BASH_ARGV0"
Loading…
Cancel
Save