-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 3/26/12 6:32 AM, Dan Douglas wrote: > Hi, hopefully a self-explanatory one today: > > ~ $ ( set -x -- {a..c}; echo "${*-"{1..3}"}" ) > + echo 'a b c' 'a b c' 'a b c' > a b c a b c a b c > > ~ $ ( set -x -- {a..c}; echo "${*/"{1..3}"/$*}" ) > + echo 'a b c' 'a b c' 'a b c' > a b c a b c a b c > > I'm told similar glitches have been found before. Looks like this applies to > anything that has this sort of replacement context that contains valid brace > expansion syntax inside quotes.
Brace expansion doesn't actually know very much shell syntax. It's a totally separate part of the word expansion process, and is completely text-based. I sometimes wish there were an expanded tracing mode, one that would display intermediate results after each stage of word expansion. I've implemented it before, but only for debugging. In this case, the first construct expands to "${*-"1"}" "${*-"2"}" "${*-"3"}" which, since the positional parameters are set, expands to three quoted strings, each containing the expansion of "$*". Similarly, the second expands to "${*/"1"/$*}" "${*/"2"/$*}" "${*/"3"/$*}" for which the substitution is unsuccessful. Chet - -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9x9nsACgkQu1hp8GTqdKsqIQCeNo0NPVoPlQYB1JSpivGxZXd7 3EAAnRdZdsnMbW3GIJEcLnhym5u/2/xc =PQoh -----END PGP SIGNATURE-----