Browse Source

file_not_found

main
pvincent 2 weeks ago
parent
commit
b44c523323
  1. 13
      poc
  2. 2
      test/poc.test.bash

13
poc

@ -160,6 +160,13 @@ function on_error {
failure_type='COMMAND_NOT_FOUND' failure_type='COMMAND_NOT_FOUND'
failure_payload="${BASH_REMATCH[3]}" failure_payload="${BASH_REMATCH[3]}"
miaou_debug "<command_not_found payload=${failure_payload}/>" miaou_debug "<command_not_found payload=${failure_payload}/>"
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 "<file_not_found payload=${failure_payload}/>"
fi
fi fi
fi fi
miaou_debug '</investigate_tmp_error>' miaou_debug '</investigate_tmp_error>'
@ -334,6 +341,12 @@ function on_exit {
unset 'tmp_error[-1]' 'tmp_error[-1]' unset 'tmp_error[-1]' 'tmp_error[-1]'
add_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" "${failure_payload}" add_miaou_error "${BASH_SOURCE[1]}" "${BASH_LINENO[0]}" "${failure_code}" "${failure_type}" "${failure_payload}"
miaou_debug '<command_not_found change_stderr />' miaou_debug '<command_not_found change_stderr />'
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 '<file_not_found change_stderr />'
elif [[ ! -v failure_type ]]; then elif [[ ! -v failure_type ]]; then
if [[ $failure_code -gt 0 && ${#tmp_error[@]} -gt 0 ]]; then if [[ $failure_code -gt 0 && ${#tmp_error[@]} -gt 0 ]]; then
last_error="${tmp_error[-1]}" last_error="${tmp_error[-1]}"

2
test/poc.test.bash

@ -57,7 +57,7 @@ fail_type subshell_term SUBSHELL_ERROR
fail_type exit EXIT fail_type exit EXIT
fail_type command_not_found COMMAND_NOT_FOUND fail_type command_not_found COMMAND_NOT_FOUND
fail_type source_not_found SOURCE_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)' fail_type subshell_error COMMAND_NOT_FOUND '(hint: prefer source than subshell)'
failed=${#failures[@]} failed=${#failures[@]}

Loading…
Cancel
Save