[Top][All Lists]

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

Re: command_not_found_handle documentation omission

From: Chet Ramey
Subject: Re: command_not_found_handle documentation omission
Date: Sun, 8 Oct 2017 10:47:11 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 10/8/17 4:54 AM, Dan Douglas wrote:
> On 10/07/2017 02:53 PM, Martijn Dekker wrote:
>> 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'.
> Yeah I wish it didn't do that. If I wanted a subshell I'd add one myself.

It was originally intended to take the place of the error message that
bash prints when it can't find a program to execute. That message was
printed by the subshell forked to execute the command, so the message could
be redirected (nearly ll shells do it that way). If you're going to run a
command, you run it in the same context as the error message.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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