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


Groups > gnu.bash.bug > #15674

Re: set -e ignored in subshell if part of command list

Path csiph.com!tncsrv06.tnetconsulting.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: set -e ignored in subshell if part of command list
Date Wed, 13 Nov 2019 11:30:05 -0500
Lines 44
Approved bug-bash@gnu.org
Message-ID <mailman.1352.1573662614.13325.bug-bash@gnu.org> (permalink)
References <CAMhR0U1fzAvXMVZacEYf9yAPwgq_6Gz5C-99dj6xt=9pQMtX8Q@mail.gmail.com> <13040a55-507d-e072-e827-be7c33be968f@case.edu> <CAMhR0U3yqJ5N-gMCOK7SspOJcdcOCEtu_+cV3=zUgr7fJmkRRQ@mail.gmail.com> <d3c4201b-85d4-eb53-fbd7-ef389f6f7f03@case.edu>
Reply-To chet.ramey@case.edu
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1573662614 1954 209.51.188.17 (13 Nov 2019 16:30:14 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu, bug-bash@gnu.org
To Shaun Crampton <shaun@tigera.io>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1573662607; bh=sw359K8P5avztldwi7ej1R29hwro1kmbyvMXaK9bDrI=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=sjeAShScEIOB9W/+x7r/7pZYpzrd+GzhoheJe31osQx0S+AvP6BO8vjUi2cZjnDNoT 0iyIvrjgQH0l6iRf4cL2DD7da43IoHGOa5YzsaNcwek86lrLLEaCck5rdYh54MUv1VD lYeBTcDFiaUvhjeSrjAWBgcARGBoLqVIRJJbryUQRETYR5YQGZEyuYeWyYnAYbszMc/ hZtuIveHYnSOoaI0TYhX9B+/nX1ohw+2wJam8znZxNsZwpzRfyH4hShrRGcsmQOqpkz sc3ERXxPbat+WgQMiEHpEhySOAxEDt5aLBWpZWNPBh0+eMMYuYAD8JQe0JY9XrGaswH cg+YGEAg==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1573662606; bh=IOo0DZaE26fL7m9noQeqiYIcvkMGQm79upEGsR2yTLU=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=XWzc8xVJdkW9zDsjJYLNzK78DV4sBShZom12FD/V1Jc9hzfdj5ao8jmoaXvLurfLUE AQWc+7K3SQlf/HIeL1Qvyn6iwwZljxInOKgICJ38HxxzOmtUc9GunEJ5wGo4paNxcLN jm3UDRLYYiLoGCFIq98UxPrWWnI8urOJw1aOTbKm4nvn8xnZdl4oltmy1MOZ3/AoALC iw+83zNgcgKTCAofxsvaj40lvgOgYnVItqwCBTFeqo06/No/OWmocKIDb6Jq918qzcH 00bPVx/NAzh4V1X5AOU5nUO6nxN3uMm3jFVL0krOmkVTKvJwy79SvrZCjvzXMBhV1dA Sv47dWlA==
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.2
In-Reply-To <CAMhR0U3yqJ5N-gMCOK7SspOJcdcOCEtu_+cV3=zUgr7fJmkRRQ@mail.gmail.com>
Content-Language en-US
X-Junkmail-Status score=8/90, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw score=8/90, refid=2.7.2:2019.11.13.153916:17:8.317, ip=, rules=DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __SUBJ_REPLY, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_REFERENCES, __REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __DKIM_ALIGNS_1, __DKIM_ALIGNS_2, __ANY_URI, __URI_MAILTO, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __BODY_NO_MAILTO, __NO_HTML_TAG_RAW, BODY_SIZE_1900_1999, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, DKIM_ALIGNS, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy]
X-Received-From 129.22.103.226
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
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 <https://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>
X-Mailman-Original-Message-ID <d3c4201b-85d4-eb53-fbd7-ef389f6f7f03@case.edu>
X-Mailman-Original-References <CAMhR0U1fzAvXMVZacEYf9yAPwgq_6Gz5C-99dj6xt=9pQMtX8Q@mail.gmail.com> <13040a55-507d-e072-e827-be7c33be968f@case.edu> <CAMhR0U3yqJ5N-gMCOK7SspOJcdcOCEtu_+cV3=zUgr7fJmkRRQ@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15674

Show key headers only | View raw


On 11/13/19 10:59 AM, Shaun Crampton wrote:
> But the commands in the subshell execute inside a different shell
> execution context so they shouldn't have
> their own set -e context (Section 2.12)?

Why? That section says the only thing that changes in the subshell 
environment is signal dispositions.

In fact, the example in the set builtin description explicitly assumes
the subshell inherits the errexit setting. The only thing the standard
requires here is that setting -e in the subshell doesn't change the
parent's setting.

But that's not exactly the point. The shell is "executing any command of an
AND-OR list other than the last" so errexit is ignored.

> 
> I don't see where the spec says that the subshell has to inherit the
> and/or list-ness of the
> parent context.  Section 2.12 doesn't mention that as being one of the
> things that a subshell inherits
> (and unless I'm missing a good use-case, it seems like a pretty
> useless thing to inherit in a subshell
> or a function that happens to be called on the LHS of an and/or).

"A subshell environment shall be created as a duplicate of the shell
environment, except that signal traps that are not being ignored shall be
set to the default action. "

It's an exact duplicate of the shell environment. It's easier to list the
exceptions rather than the long list of things it inherits (more than the
list earlier in that section).

In any event, it's how existing shells behave, and the standard is
attempting to match existing practice. In fact, part of the proposed
language from 2009, when this was debated at length, was "The -e option is
ignored and cannot be enabled by any command run by these lists" but that
was considered unnecessary.

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

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


Thread

Re: set -e ignored in subshell if part of command list Chet Ramey <chet.ramey@case.edu> - 2019-11-13 11:30 -0500

csiph-web