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


Groups > gnu.bash.bug > #15599

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

Path csiph.com!weretis.net!feeder6.news.weretis.net!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 Fri, 15 Nov 2019 07:57:46 -0500
Lines 43
Approved bug-bash@gnu.org
Message-ID <mailman.1557.1573822678.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> <1573772541.924.11.camel@debian.16bits.net> <e36f54b8-a3cd-fa84-0fb8-993c8fd49fe4@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 8bit
X-Trace usenet.stanford.edu 1573822679 27898 209.51.188.17 (15 Nov 2019 12:57:59 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu
To Ángel <angel@debian.16bits.net>, bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1573822668; bh=/KDaol2ovmq+XtMONyrjdBsJ7agss8J1uJgBHk8pgcg=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=rzqGLRpdmxIt4UlW7G2aJIVWd7vkswRvoenzkhk+JwxB8efg91qGQ9/VkxZf18HMNM OqFoLR+0R1K0Mbm3VULolGi4kZpULRxMck8DCc0EeFgPS9y7ECYQYwOxBgUpvRCJdJA 2JeqQJUn9b+PdiwY1H+4i6dWGQ+oZiqdgMPeZh5s9MZso9Swr1N3rcwZpNLg4OzOEKO bxySnDJb77xMWq+XHDJB1yk4U6d597oCsblWuUru/1fziM1IKJOUSuLoYaJXrWNIybx wq7XB3QOB7Y7NL8k4a1g99CqejYy5CEwAwKs8bodBvhKnB8zrAQFCZGHqS2DZTM4d8p Zt4+wodA==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1573822667; bh=2hUNFRn41SbF0rpScX7qJqRyQ1Dwk6M3aQvCGmglJTI=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=YGiMlqDpWKaT9g/6i/ZvrF7U0FBsNCcrZLuA8kVKfS7KUsCWAnUU8PY+QS5aDsRBv1 Jy6Ae1Kk3qxz47QH+6y7YhHFvVhk0UuYsTCVBa+hPtBWH9CeTEK5mmPjUXCGx+UokUg MXkc9oS//26av/Q39P+gM9wQN2i6bLXinz+o/gHmxxyU6D2Mmil9xsJdiSpE7koLJ9z AM2IR3xKNUWO1GbEfVBBpTT+6m64NXDghh20CntTjG9YiFfWfev3hqeB92wSIrUQ2qs wT7r3Q4V/wRpdNAcvQBPoVdteQQ1Ur6KCAoZ8U1hf+d9hq8ze3KrXrMVHrFM9J8/zpR B7WO43sw==
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.2
In-Reply-To <1573772541.924.11.camel@debian.16bits.net>
Content-Language en-US
X-Junkmail-Status score=7/90, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw score=7/90, refid=2.7.2:2019.11.15.123316:17:7.944, ip=, rules=DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __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_CC1, __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, BODY_SIZE_1700_1799, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, DKIM_ALIGNS, BODY_SIZE_5000_LESS, [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.195
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 <e36f54b8-a3cd-fa84-0fb8-993c8fd49fe4@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> <d3c4201b-85d4-eb53-fbd7-ef389f6f7f03@case.edu> <1573772541.924.11.camel@debian.16bits.net>
Xref csiph.com gnu.bash.bug:15599

Show key headers only | View raw


On 11/14/19 6:02 PM, Ángel wrote:
> On 2019-11-13 at 11:30 -0500, Chet Ramey wrote:
>> 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 would say that the confusing part is that the behavior of the subshell
> is dependant on *where* it is being executed in the parent.
> 
> In general terms, I would expect
>    ( <code> )
> to be roughly equivalent to
>    bash -c "<code>"
> 
> i.e. <code> being executed on its own context and unable to affect the
> parent

That's not a good assumption. When the shell executes a command in a
subshell, it forks and executes the command. The subshell is an exact
copy of its parent, so of course it depends on the parent's state at
the time it's created. The subshell being unable to affect the parent's
state is just a consequence of the relationship between processes.
If you want to execute something in a `pristine' environment, you can use
`bash -c' as you showed.

-- 
``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-15 07:57 -0500

csiph-web