bug-bash
[Top][All Lists]
Advanced

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

Re: incorrect brace expansion when using default values


From: Chris F.A. Johnson
Subject: Re: incorrect brace expansion when using default values
Date: Wed, 6 Sep 2006 06:44:24 -0400
User-agent: slrn/0.9.8.1 (Linux)

On 2006-09-06, Andreas Schwab wrote:
> address@hidden (Paul Jarc) writes:
>
>> Mike Frysinger <address@hidden> wrote:
>>> this little bit of code doesnt work right:
>>> foo() { echo "${1:-a{b,c}}" ; }

   The first '}' is interpreted as the end of the parameter expansion.

>>
>> Brace expansion happens before parameter expansion (man bash,
>> EXPANSION).
>
> Brace expansion doesn't come into play here, because the braces are
> quoted.

   Quote them, and they do expand:

$ foo() { echo "${1:-"a{b,c}"}" ; }
$ foo
ab ac

   However, there is a problem:

$ foo 1
1 1

   Where is the second '1' coming from?

-- 
   Chris F.A. Johnson                      <http://cfaj.freeshell.org>
   ===================================================================
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)




reply via email to

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