bug-bash
[Top][All Lists]
Advanced

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

Re: command substitution is stripping set -e from options


From: Chet Ramey
Subject: Re: command substitution is stripping set -e from options
Date: Sat, 10 Oct 2015 13:24:36 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 10/8/15 2:36 PM, Christoph Gysin wrote:
>> I think you're overlooking what I referred to above: that the exit status
>> of a command substitution doesn't have any effect on whether the parent's
>> command succeeds or fails except in one case: the right-hand-side of an
>> assignment statement that is the last assignment in a command consisting
>> only of assignment statements.  To say that it `disables the whole point
>> of set -e' is a considerable overstatement.
> 
> Well, I do see your point. But my understanding was that if I wanted
> to run all my bash code with set -e error checking, I can do so by
> avoiding a couple of corner cases, namely:

There are many more cases where the setting of -e has no effect.  We
discussed this extensively on the posix mailing list a few years ago,
and the result of that discussion is at

http://austingroupbugs.net/view.php?id=52

For example, even if you attempt to enable -e in a shell function, it
will have no effect if you run it as the command after `if'.

It seems like you're restricting the discussion to simple commands only,
and only to those commands that contain command subsitutions.  I think
this is what Greg is talking about.

I will consider adding an option to change the behavior of command
substitution inheriting the -e option, since there doesn't seem to be
any way to decouple this behavior from posix mode.

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



reply via email to

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