From 98deda9e6c2e27e7ba8fd01be350b8115f434cb7 Mon Sep 17 00:00:00 2001 From: pvincent Date: Sat, 25 Jul 2026 14:34:07 +0400 Subject: [PATCH] command error --- bin/miaou-bash | 7 +------ test/miaou-bash.test.bash | 1 + test/stub/extra/library.bash | 5 +++-- test/stub/scenario.bash | 5 +++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/miaou-bash b/bin/miaou-bash index 174e945..e00ceaa 100755 --- a/bin/miaou-bash +++ b/bin/miaou-bash @@ -162,7 +162,6 @@ function on_exit { fi else failure_payload="${last_error}" - miaou_debug "UNDEFINED last error=${last_error}" regex="╟─⟶" if [[ "$last_error" =~ $regex ]]; then last_trim=false # keep the last error for next stacktrace @@ -174,11 +173,7 @@ function on_exit { stack_functions[0]="${stack_functions[0]} (hint: prefer source than subshell)" [[ "${code}" == 128 ]] && failure_type='SUBSHELL_SOURCE_NOT_FOUND' else - failure_type='UNDEFINED' - regex='^subshell term:' - if [[ "$last_error" =~ $regex ]]; then - failure_type='SUBSHELL_TERM2' - fi + failure_type='COMMAND_ERROR' fi fi diff --git a/test/miaou-bash.test.bash b/test/miaou-bash.test.bash index 57ce1de..25b060f 100755 --- a/test/miaou-bash.test.bash +++ b/test/miaou-bash.test.bash @@ -70,6 +70,7 @@ fail_type exit EXIT fail_type source_not_found SOURCE_NOT_FOUND fail_type file_not_found FILE_NOT_FOUND fail_type subshell_error COMMAND_NOT_FOUND '(hint: prefer source than subshell)' +fail_type command_error COMMAND_ERROR failed=$((TEST_COUNT - SUCCESS_COUNT)) diff --git a/test/stub/extra/library.bash b/test/stub/extra/library.bash index 10430e4..3f996ec 100755 --- a/test/stub/extra/library.bash +++ b/test/stub/extra/library.bash @@ -11,11 +11,12 @@ function blabla { function suite { command_not_found - echo $nope + grep nope nope + exit exit 10 # youpi + echo $nope return 7 return - exit } blabla diff --git a/test/stub/scenario.bash b/test/stub/scenario.bash index 782d1e0..dcedd75 100755 --- a/test/stub/scenario.bash +++ b/test/stub/scenario.bash @@ -94,6 +94,11 @@ function do_subshell_error { "$BASEDIR/extra/library.bash" } +function do_command_error { + >&2 echo nope is not defined! + grep nope nope +} + # FUNCTIONS function call_function_which_will_exit {