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, 3 Oct 2015 15:52:40 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 10/2/15 9:22 AM, Greg Wooledge wrote:
> On Fri, Oct 02, 2015 at 03:53:42PM +0300, Christoph Gysin wrote:
>> I'm still curious as to why set -e is stripped in the first place?
> 
> Chet can give the definitive answer, but my take is that it's a huge
> surprise to someone writing a function independent of the script, or
> using a function that was written independently of the script.  

It's been over 20 years, and we weren't as detailed with our change logs
back then, but I imagine the rationale was similar to the above with the
addition of something like the following:

The parent shell (the one that enabled -e) should be the one to make the
decision about whether or not the shell exits.  The exit status of the
command substitution doesn't make a difference except in one special case,
so inheriting errexit and exiting (possibly prematurely) doesn't really
help the parent decide whether or not to exit.

Now, of course, it's been more than 20 years, and backwards compatiblity
is a concern.

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



reply via email to

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