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


Groups > gnu.bash.bug > #11603

Re: command substitution is stripping set -e from options

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail
From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: command substitution is stripping set -e from options
Date Sat, 10 Oct 2015 13:24:36 -0400
Organization ITS, Case Western Reserve University
Lines 34
Approved bug-bash@gnu.org
Message-ID <mailman.54.1444497929.7904.bug-bash@gnu.org> (permalink)
References <CADex794C1jOf0wrB298_O4ohAqZghYUdd9DJcuaOvV1dCP5AOQ@mail.gmail.com> <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> <56103208.30406@case.edu> <CADex794ttQa_b9NBGKJMsXj36yoRL3JQ16aja=S8=hAxGgzCQA@mail.gmail.com> <56168B10.1000905@case.edu> <CADex796=T3x11Y5Tz7udh7UzpYDaOY+0-EatZrAu2hGNRZ=gqg@mail.gmail.com>
Reply-To chet.ramey@case.edu
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1444497929 22256 208.118.235.17 (10 Oct 2015 17:25:29 GMT)
X-Complaints-To action@cs.stanford.edu
Cc Greg Wooledge <wooledg@eeg.ccf.org>, bug-bash@gnu.org, chet.ramey@case.edu
To Christoph Gysin <christoph.gysin@gmail.com>
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
In-Reply-To <CADex796=T3x11Y5Tz7udh7UzpYDaOY+0-EatZrAu2hGNRZ=gqg@mail.gmail.com>
X-Junkmail-Whitelist YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
X-Received-From 129.22.105.36
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:11603

Show key headers only | View raw


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    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-10 13:24 -0400

csiph-web