bug-bash
[Top][All Lists]
Advanced

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

Re: Brace expansion inside of command substitution - broken or is it me?


From: Andreas Schwab
Subject: Re: Brace expansion inside of command substitution - broken or is it me?
Date: Fri, 18 Feb 2011 22:53:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.94 (gnu/linux)

Greg Wooledge <address@hidden> writes:

> On Fri, Feb 18, 2011 at 10:32:13PM +0100, Peter Hofmann wrote:
>> 
>>  $ echo "$(echo "{1..3}")"
>>  1 2 3
>> 
>> Huh?
>
> Brace expansion is a funny thing.  My belief at the moment -- I'm sure
> someone will correct me if I'm wrong -- is that because you've got
> everything quoted up, it's all seen as one "word" by the parser.  And
> it's a word that just happens to have a brace expansion in it.  So,
> the parser expands it out something like this:
>
> $ echo "$(echo "1")" "$(echo "2")" "$(echo "3")"
>
> Counting PIDs on my sequentially-generating-PIDs OS seems to confirm that
> it's running three child processes, so that lends a tiny bit of evidence
> to my theory.

$ set -x
$ echo "$(echo "{1..3}")"
++ echo 1
++ echo 2
++ echo 3
+ echo 1 2 3
1 2 3

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

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