function

command_not_found_handle

If defined, invoked for unsuccessful normal command lookup in a separate execution environment, with command name and arguments. Its status becomes the failed lookup status. Do not treat it as a universal error handler.

Formal Syntax & Structure

bash syntaxbash
command_not_found_handle() { list; }

Return Value

exit status

If defined, invoked for unsuccessful normal command lookup in a separate execution environment, with command name and arguments. Its status becomes the failed lookup status. Do not treat it as a universal error handler.

Working Example

Example Snippetbash
marker=parentcommand_not_found_handle() {    marker=child    printf 'missing=%s\n' "$1"    return 42}bm_missing_command_8f12printf 'status=%s marker=%s\n' "$?" "$marker"
Bash Reference