[Top][All Lists]

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

Re: incorrect brace expansion when using default values

From: Mike Frysinger
Subject: Re: incorrect brace expansion when using default values
Date: Tue, 5 Sep 2006 21:57:37 -0400
User-agent: KMail/1.9.4

On Tuesday 05 September 2006 19:01, Paul Jarc wrote:
> Mike Frysinger <address@hidden> wrote:
> > this little bit of code doesnt work right:
> > foo() { echo "${1:-a{b,c}}" ; }
> Brace expansion happens before parameter expansion (man bash,
> EXPANSION).  So the first "}" ends the parameter expression, and the
> second "}" isn't special.  The result of parameter expansion is not
> subject to brace expansion.

i dont think order is why it's behaving differently from what i expect ... 
after all, if brace expansion happened before the parameter expansion, it 
should have assigned "ab ac" as the default value, not "a{b,"

i think this little tidbit is what matters:
   Parameter Expansion
       When  braces  are  used, the matching ending brace is the first `}' not
       escaped by a backslash or within a quoted string,  and  not  within  an
       embedded  arithmetic  expansion,  command  substitution,  or  parameter

since brace expansion is not listed here as an exception, the behavior i'm 
seeing is correct

> > $ foo
> > a{b,c}
> This is correct.  "a{b,c" is the default value, and "}" follows the
> parameter expression.
> > $ foo 1
> > a}
> I get "1}".

sorry, yes this is what i get ... i was hand typing the e-mail ;)

Attachment: pgpVyjvP3ihLp.pgp
Description: PGP signature

reply via email to

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