help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Option execfail does not work in subshells


From: Chet Ramey
Subject: Re: [Help-bash] Option execfail does not work in subshells
Date: Mon, 14 Aug 2017 10:52:14 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 8/9/17 1:50 PM, address@hidden wrote:
> On Tue, 8 Aug 2017 17:04:12 +0200
> "R. Diez" <address@hidden> wrote:
>>
>>> `execfail' only works when the shell is interactive.  Subshells are
>>> not considered interactive shells.  
>>
>> But that is not what the documentation says:
>>
>> -----8<-----8<-----8<-----
>> execfail
>>
>> If this is set, a non-interactive shell will not exit if it cannot 
>> execute the file specified as an argument to the exec builtin command. 
>> An interactive shell does not exit if exec fails.
>> -----8<-----8<-----8<-----
> <snip>
> 
> Notice that the two statements above are similar but not the *same*.

The second sentence is intended to be the same as the first, but shorter
to avoid saying the same thing multiple times; the only difference is
whether or not the shell is interactive.

>> If this is set, a non-interactive shell will not exit if it cannot 
>> execute the file specified as an argument to the exec builtin command. 
> See the word "file", it's not equivalent to the word "function"[1].

True, but it doesn't matter in this case, since the example does not
have exec attempting to execute a shell function. `exec' always treats
its argument as an executable file.

> Notice also that exec could fail for other reasons which are not listed
> above but also not covered.

But execfail doesn't cover those. The idea behind execfail is that if
execve fails, the shell doesn't exit.

>> An interactive shell does not exit if exec fails.
> OTOH, an interactive shell would not exit if, for *any* reason exec fails.

You're reading too much into it. The only other reasons the builtin would
fail is if given an invalid option or if the shell is restricted, and
execfail doesn't act on those cases. The shell doesn't exit if those happen.

-- 
``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/



reply via email to

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