|
|
|
@ -163,6 +163,7 @@ function on_error { |
|
|
|
function on_pipe { |
|
|
|
trap - RETURN |
|
|
|
local tmp_error regex source lineno |
|
|
|
miaou_debug "<on_pipe sub_pid=$BASHPID pid=$$>" |
|
|
|
|
|
|
|
error_source=("${BASH_SOURCE[@]}") |
|
|
|
error_lineno=("${BASH_LINENO[@]}") |
|
|
|
@ -171,7 +172,8 @@ function on_pipe { |
|
|
|
unset 'error_source[-1]' 'error_lineno[-1]' 'error_funcname[-1]' |
|
|
|
unset 'error_source[-1]' 'error_lineno[-1]' 'error_funcname[-1]' |
|
|
|
|
|
|
|
mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
|
miaou_debug '<load_tmp_error/>' && mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
|
|
|
|
|
last_error="${tmp_error[-1]}" |
|
|
|
regex='^(.*): line ([0-9]+): miaou_error: SUBSHELL_ERROR ([0-9]+) payload: (.*)$' |
|
|
|
if [[ $last_error =~ $regex ]]; then |
|
|
|
@ -187,7 +189,7 @@ function on_pipe { |
|
|
|
failure_code=141 |
|
|
|
failure_type="PIPE_ERROR" |
|
|
|
fi |
|
|
|
miaou_debug "<on_pipe code=$failure_code sub_pid=$BASHPID pid=$$ />" |
|
|
|
miaou_debug "</on_pipe/>" |
|
|
|
builtin exit "$failure_code" |
|
|
|
} |
|
|
|
|
|
|
|
@ -249,7 +251,9 @@ function on_exit { |
|
|
|
|
|
|
|
miaou_debug "<on_exit code=$code>" |
|
|
|
|
|
|
|
[[ ! -v tmp_error ]] && mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
|
[[ ! -v tmp_error ]] && |
|
|
|
miaou_debug '<load_tmp_error/>' && |
|
|
|
mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
|
|
|
|
|
if [[ -v failure_type && "$failure_type" == 'RETURN' ]]; then |
|
|
|
last_error="${tmp_error[-1]}" |
|
|
|
@ -274,13 +278,10 @@ function on_exit { |
|
|
|
regex='^(.*): line ([0-9]+): (.*): unbound variable$' |
|
|
|
if [[ "$last_error" =~ $regex ]]; then |
|
|
|
local source line payload |
|
|
|
|
|
|
|
source="${BASH_REMATCH[1]}" |
|
|
|
line="${BASH_REMATCH[2]}" |
|
|
|
payload="${BASH_REMATCH[3]}" |
|
|
|
miaou_debug "<unbound_variable source=${source} line=${line} payload={${payload}} >" |
|
|
|
failure_code=$code |
|
|
|
failure_type='UNBOUND_VARIABLE' |
|
|
|
failure_payload="${BASH_REMATCH[3]}" |
|
|
|
error_source=("${BASH_SOURCE[@]}") |
|
|
|
error_lineno=("${BASH_LINENO[@]}") |
|
|
|
error_funcname=("${FUNCNAME[@]}") |
|
|
|
@ -290,6 +291,11 @@ function on_exit { |
|
|
|
error_source=("$source" "${error_source[@]}") |
|
|
|
error_lineno=("$line" "${error_lineno[@]}") |
|
|
|
error_funcname=("${error_funcname[@]}" '<main>') |
|
|
|
|
|
|
|
failure_code=$code |
|
|
|
failure_type='UNBOUND_VARIABLE' |
|
|
|
failure_payload=$payload |
|
|
|
miaou_debug "<unbound_variable source=${source} line=${line} payload={${failure_payload}}>" |
|
|
|
fi |
|
|
|
fi |
|
|
|
miaou_debug "</on_exit_tmp_error>" |
|
|
|
|