diff --git a/poc b/poc
index 6922ba7..02e60df 100755
--- a/poc
+++ b/poc
@@ -49,6 +49,25 @@ function is_true {
function miaou_debug {
is_true "${MIAOU_DEBUG}" && >&4 builtin echo -e "\e[90m <== DEBUG ==> \e[33m$*\e[0m" || true
}
+# overridden function which permits backtracing of the original `exit` statement
+function exit {
+ failure_code=${1:-0}
+ failure_type="EXIT"
+ miaou_debug ""
+ print_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}"
+
+ error_source=("${BASH_SOURCE[@]}")
+ error_lineno=("${BASH_LINENO[@]}")
+ error_funcname=("${FUNCNAME[@]}")
+ unset 'error_source[-1]' 'error_lineno[-1]' 'error_funcname[-1]'
+ unset 'error_source[0]' 'error_lineno[-1]' 'error_funcname[0]'
+ error_funcname[-1]=''
+ error_source=("${error_source[@]}")
+ error_lineno=("${error_lineno[@]}")
+ error_funcname=("${error_funcname[@]}")
+
+ builtin exit "$failure_code"
+}
function tty_ansi {
local code
@@ -70,7 +89,7 @@ function print_miaou_error {
function on_error {
failure_code="${1:-200}"
- >&4 printf '\r' # force carriage return explicitly
+ >&4 printf '\r' # TODO: force carriage return explicitly, is it really useful?
if [[ $$ == "$BASHPID" ]]; then
miaou_debug ""
@@ -87,7 +106,7 @@ function on_error {
error_lineno=("${error_lineno[@]}")
error_funcname=("${error_funcname[@]}")
- exit "$failure_code"
+ builtin exit "$failure_code"
else
miaou_debug ""
print_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" 'SUBSHELL_ERROR'
@@ -122,7 +141,7 @@ function on_pipe {
failure_type="PIPE_ERROR"
fi
miaou_debug ""
- exit "$failure_code"
+ builtin exit "$failure_code"
}
function dump_stderr {
@@ -234,7 +253,7 @@ trap 'on_error $?' ERR
trap 'on_exit $?' EXIT
trap 'on_pipe' PIPE
-if [[ -e /proc/$$/fd/3 ]]; then exec 4>&3 3>&-; else exec 4>/dev/tty; fi
+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 ""
diff --git a/test/stub/scenario.bash b/test/stub/scenario.bash
index ecb4aa2..a9fef6a 100755
--- a/test/stub/scenario.bash
+++ b/test/stub/scenario.bash
@@ -113,7 +113,6 @@ function do_command_error {
function call_function_which_will_exit {
exit 99
-
}
function F2 {