Browse Source

before miaou_debug auto-hierarchy

main
pvincent 2 weeks ago
parent
commit
df6628be61
  1. 23
      poc

23
poc

@ -229,8 +229,10 @@ function on_exit {
trap - RETURN
local code="${1:-0}" last_error regex
mapfile -t tmp_error <"$MIAOU_BASH_ERROR"
2>&3 >&3 dump_stderr
miaou_debug "<on_exit code=$code>"
[[ ! -v tmp_error ]] && mapfile -t tmp_error <"$MIAOU_BASH_ERROR"
if [[ -v failure_type && "$failure_type" == 'RETURN' ]]; then
last_error="${tmp_error[-1]}"
regex='^(.*): line ([0-9]+): miaou_error: RETURN [0-9]+'
@ -249,7 +251,7 @@ function on_exit {
else
if [[ $code -gt 0 && ${#tmp_error[@]} -gt 0 ]]; then
last_error="${tmp_error[-1]}"
miaou_debug "<on_exit exit=$code last_error='$last_error'>"
miaou_debug "<on_exit_tmp_error last='$last_error'>"
if [[ $code -eq 1 ]]; then
regex='^(.*): line ([0-9]+): (.*): unbound variable$'
if [[ "$last_error" =~ $regex ]]; then
@ -272,16 +274,20 @@ function on_exit {
error_funcname=("${error_funcname[@]}" '<main>')
fi
fi
miaou_debug "</on_exit_tmp_error>"
fi
miaou_debug "</on_exit>"
fi
if [[ $code -gt 0 && -v failure_type ]]; then
2>&3 >&3 dump_stderr
if [[ -v failure_type ]]; then
2>&3 >&4 dump_failure
2>&3 >&4 dump_stacktrace
fi
miaou_debug "</source type=failure exit=$code pid=${BASHPID}>"
if [[ $code -gt 0 ]]; then
miaou_debug "</on_exit exit=$code>"
else
miaou_debug "</on_exit success>"
fi
}
## main
@ -301,7 +307,6 @@ trap 'on_return' RETURN
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 from=$BASH_ARGV0 pid=${BASHPID} />"
# shellcheck source=/dev/null
source "$BASH_ARGV0"
miaou_debug "</source type=success pid=${BASHPID}>"
Loading…
Cancel
Save