bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

command_not_found_handle documentation omission


From: Martijn Dekker
Subject: command_not_found_handle documentation omission
Date: Sat, 7 Oct 2017 21:53:43 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

The bash manual and info pages state:

| If the search is unsuccessful, the shell searches for a
| defined shell function named 'command_not_found_handle'.  If that
| function exists, it is invoked with the original command and the
| original command's arguments as its arguments, and the function's
| exit status becomes the exit status of the shell.

This fails to mention that command_not_found_handle() is run in the
subshell forked to 'exec' the command, so even an explicit 'exit' will
not exit anything but that subshell. It also means a command handler
can't do anything that influences the main shell, except send it a
signal with 'kill'.

The phrasing "the function's exit status becomes the exit status of the
shell" is misleading to anyone without this knowledge, as it implies
that the shell will exit with that status, whereas in fact all that
happens is that $? is set to the function's exit status.

- Martijn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]