|
From: | Tatavarty Kalyan |
Subject: | Re: incorrect brace expansion when using default values |
Date: | Thu, 7 Sep 2006 14:20:43 +0800 |
On 9/6/06, Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
On 2006-09-06, Andreas Schwab wrote: > prj@po.cwru.edu (Paul Jarc) writes: > >> Mike Frysinger <vapier@gentoo.org> 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?
It seems foo() { echo "${1:-"a{b,c}"}" ; } expands to foo() { echo ${1:-ab} ${1:-ac} ; }
-- Chris F.A. Johnson <http://cfaj.freeshell.org> =================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
[Prev in Thread] | Current Thread | [Next in Thread] |