bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EXIT trap in implicit vs. explicit pipeline subshell


From: Chet Ramey
Subject: Re: EXIT trap in implicit vs. explicit pipeline subshell
Date: Fri, 12 Jun 2015 11:40:48 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/12/15 1:25 AM, Miroslav Koskar wrote:
> On Jun 11 09:35, Chet Ramey wrote:
>> On 6/11/15 4:08 AM, Miroslav Koskar wrote:
>>
>>> In fact group command { ... } would work too, as I've showed and you've
>>> confirmed. One last bit here I guess, why is it that the $BASH_SUBSHELL
,
>>> would not reflect that is it in fact running in subshell?
>>
>> BASH_SUBSHELL measures (...) subshells, not pipeline elements.  For
>> example, the following lines show that it has value `1':
>>
>> ( echo in subshell: $BASH_SUBSHELL )
>> ( echo in subshell pipeline: $BASH_SUBSHELL ) | cat
> 
> Ok, I probably use term "subshell" too loosely, like everything running
> in a separate process introducing separate shell environment. I'm sure
> there are more nuances to that. Man page on pipeline explicitly states
> that it is running parts in a subshell. That is true in that broader
> sense, so maybe extending BASH_SUBSHELL man section to say it doesn't
> apply for pipeline parts/elements then but only (...)?

I'm going to think about whether I should document the status quo or expand
the definition of `subshell' that $BASH_SUBSHELL reflects.  It seems like
group commands in pipelines (and the exit traps they run) would be a good
candidate for such an expansion.

Chet

- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAlV6/XcACgkQu1hp8GTqdKsbgQCfS5GwVFFgEXO00NU5QUbWS6iD
JLwAnRpijqZqg0dytqpkPHanTiXVA8SW
=As9m
-----END PGP SIGNATURE-----



reply via email to

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