On Sunday, February 19, 2012 04:25:46 PM Chet Ramey wrote: > I assume you mean the first one. It doesn't matter whether or not the > variable is set as a side effect of the redirection -- it's in a > subshell and disappears. > > Chet
Forgot to mention though, It's possible in ksh there is no subshell created if you consider this: $ : "$(</dev/null${ echo ${.sh.subshell} >&2;})" 1 $ : $(: $( echo ${.sh.subshell} >&2)) 2 It even works with the subshell-less command substitution, but there's no typeset output, so either x is automatically unset, it's never set to begin with, or ${ <x;} is a special case that does create a subshell: $ ({ echo "${ {x}</dev/stdin;}"; } <<<'test'; typeset -p x) test Is a subshell really needed for this? (it's still significantly faster than the cat loadable builtin even with the subshell) That test could very well be invalid too. Nothing is ever as it seems when it comes to subshells. ~ $ : | echo $BASH_SUBSHELL >&2 | : 0 ~ $ : | { echo $BASH_SUBSHELL >&2; } | : 1 ~ $ : | ( echo $BASH_SUBSHELL >&2; ) | : 1 ~ $ : | ( ( echo $BASH_SUBSHELL >&2; ) ) | : 2 ~ $ : | { ( echo $BASH_SUBSHELL >&2; ) } | : 2 ~ $ : | { { echo $BASH_SUBSHELL >&2; } } | : 1 -- Dan Douglas