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: Chet Ramey
Subject: Re: incorrect brace expansion when using default values
Date: Fri, 08 Sep 2006 23:03:12 -0400
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)

Chris F.A. Johnson wrote:

>    Quote them, and they do expand:
> 
> $ foo() { echo "${1:-"a{b,c}"}" ; }
> $ foo
> ab ac

Brace expansion is essentially separate from the rest of the expansions:
in fact, it's designed to be part of a separate library if desired.  As
such, it doesn't implement all of the shell's somewhat quirky quoting
semantics.  It understands simple single- and double-quoted strings and
backslash escapes.  The manual is perhaps not as clear about this as it
could be.

The quoted string, once the brace expansion code finishes, comes out like
this:

"${1:-a"b"}" "${1:-a"c"}"

>From there, the results observed should be understandable.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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