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: David Niklas
Subject: Re: [Help-bash] Option execfail does not work in subshells
Date: Wed, 16 Aug 2017 09:53:42 -0400

On Mon, 14 Aug 2017 10:52:14 -0400
Chet Ramey <address@hidden> wrote:
> 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.

I'm used to manuals where if something is said differently, then it means
something different.
Why not use the short version for both?

> >> 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.

I mean that exec is a builtin which is a C function (I would imagine), and
is not a program, but a builtin. But that is probably another case
of reading too much into what was written.

> > 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.

What about having incorrect permissions for the file, like read but no
exec, or exec but no read?
Or, how about an OOM condition?

Sincerely,
David



reply via email to

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