[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: |
Greg Wooledge |
Subject: |
Re: Brace expansion inside of command substitution - broken or is it me? |
Date: |
Fri, 18 Feb 2011 17:01:16 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Fri, Feb 18, 2011 at 10:53:31PM +0100, Andreas Schwab wrote:
> Greg Wooledge <wooledg@eeg.ccf.org> 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.
So... what I said was correct?
If I expand it out the way I said, and do your set -x trick, I get the
same output:
imadev:~$ set -x
imadev:~$ echo "$(echo "1")" "$(echo "2")" "$(echo "3")"
++ echo 1
++ echo 2
++ echo 3
+ echo 1 2 3
1 2 3
So I think you're saying I'm correct.