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 (...)? But let's look at this: { echo $BASH_SUBSHELL; trap 'echo EXIT-$$.$BASHPID.$BASH_SUBSHELL' EXIT } | cat Output: 1 EXIT-3706.3714.0 Is there an explanation and reason to not have BASH_SUBSHELL in above case consistent? I've gathered that both should be 0, to be consistent with above statements. PS: Thanks for clarification on those other points in previous reply Miro -- Miroslav Koskar http://mkoskar.com/
signature.asc
Description: PGP signature