diff --git a/poc b/poc index c6b2c28..4cd9dc1 100755 --- a/poc +++ b/poc @@ -105,6 +105,8 @@ function on_error { failure_code="${1:-200}" >&4 printf '\r' # TODO: force carriage return explicitly, is it really useful? + miaou_debug "" + if [[ $$ == "$BASHPID" ]]; then if [[ ! -v failure_type ]]; then if [[ ${BASH_COMMAND} == 'false' ]]; then @@ -116,12 +118,6 @@ function on_error { print_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" fi - if [[ -v failure_payload ]]; then - miaou_debug "" - else - miaou_debug "" - fi - error_source=("${BASH_SOURCE[@]}") error_lineno=("${BASH_LINENO[@]}") error_funcname=("${FUNCNAME[@]}") @@ -132,9 +128,15 @@ function on_error { error_lineno=("${error_lineno[@]}") error_funcname=("${error_funcname[@]}") + if [[ -v failure_payload ]]; then + miaou_debug "" + else + miaou_debug "" + fi + builtin exit "$failure_code" else - miaou_debug "" + miaou_debug "" print_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" 'SUBSHELL_ERROR' "${BASH_COMMAND}" kill -PIPE $$ fi diff --git a/test/poc.test.bash b/test/poc.test.bash index f1b8562..dca5bdb 100755 --- a/test/poc.test.bash +++ b/test/poc.test.bash @@ -43,11 +43,13 @@ function fail_type { set -uo pipefail assert success + fail_type subshell_term SUBSHELL_ERROR fail_type unbound_variable UNBOUND_VARIABLE fail_type unbound_associative UNBOUND_VARIABLE fail_type false FALSE -fail_type return RETURN +fail_type last_false COMMAND_ERROR +fail_type subshell_term SUBSHELL_ERROR fail_type exit EXIT fail_type command_not_found COMMAND_NOT_FOUND # fail_type source_not_found SOURCE_NOT_FOUND diff --git a/test/stub/scenario.bash b/test/stub/scenario.bash index 958f803..29e15c7 100755 --- a/test/stub/scenario.bash +++ b/test/stub/scenario.bash @@ -28,8 +28,9 @@ function do_subshell_term { # echo SHOULD NOT SHOW UP! } +# unable to catch up error when the last command is `!` statement function do_last_false { - # FIXME: provides error detection + echo 'last false' ! true }