Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11578

Re: command substitution is stripping set -e from options

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: command substitution is stripping set -e from options
Date 2015-10-03 15:52 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.382.1443902015.16064.bug-bash@gnu.org> (permalink)
References (1 earlier) <560D83DA.9020405@redhat.com> <CADex795r=oqZ7iv4TxrjUn9coDUnu=PgPngkfRWA1f7EZyohfA@mail.gmail.com> <20151002122925.GK25574@eeg.ccf.org> <CADex797-gWHRzpy=gsdORZtU=Os5Qe6f=LwJ7xJ-N-6oHZdd3w@mail.gmail.com> <20151002132221.GL25574@eeg.ccf.org>

Show all headers | View raw


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/

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: command substitution is stripping set -e from options Chet Ramey <chet.ramey@case.edu> - 2015-10-03 15:52 -0400

csiph-web