From b44c523323e7eb0ab12d8c0548ea182576ddbe43 Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 29 Jul 2026 23:17:34 +0400 Subject: [PATCH] file_not_found --- poc | 13 +++++++++++++ test/poc.test.bash | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/poc b/poc index b91e352..677a1c4 100755 --- a/poc +++ b/poc @@ -160,6 +160,13 @@ function on_error { failure_type='COMMAND_NOT_FOUND' failure_payload="${BASH_REMATCH[3]}" miaou_debug "" + else + regex='^(.*): line ([0-9]+): (.*): No such file or directory$' + if [[ $failure_code == 127 && "$last_error" =~ $regex ]]; then + failure_type='FILE_NOT_FOUND' + failure_payload="${BASH_REMATCH[3]}" + miaou_debug "" + fi fi fi miaou_debug '' @@ -334,6 +341,12 @@ function on_exit { unset 'tmp_error[-1]' 'tmp_error[-1]' add_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" "${failure_payload}" miaou_debug '' + + elif [[ -v failure_type && "$failure_type" == 'FILE_NOT_FOUND' ]]; then + unset 'tmp_error[-1]' 'tmp_error[-1]' + add_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" "${failure_payload}" + miaou_debug '' + elif [[ ! -v failure_type ]]; then if [[ $failure_code -gt 0 && ${#tmp_error[@]} -gt 0 ]]; then last_error="${tmp_error[-1]}" diff --git a/test/poc.test.bash b/test/poc.test.bash index da7ade9..f1bf4ec 100755 --- a/test/poc.test.bash +++ b/test/poc.test.bash @@ -57,7 +57,7 @@ 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 -fail_type file_not_found FILE_NOT_FOUND '(hint: prefer source than subshell)' +fail_type file_not_found FILE_NOT_FOUND fail_type subshell_error COMMAND_NOT_FOUND '(hint: prefer source than subshell)' failed=${#failures[@]}