bug-bash
[Top][All Lists]
Advanced

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

Re: excess braces ignored: bug or feature ?


From: Dan Douglas
Subject: Re: excess braces ignored: bug or feature ?
Date: Mon, 20 Feb 2012 03:17:14 -0600
User-agent: KMail/4.7.4 (Linux/3.1.6-pf; KDE/4.7.4; x86_64; ; )

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



reply via email to

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