bug-bash
[Top][All Lists]
Advanced

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

Re: strange expansion of <(cat p.main.{optional,extra})


From: Lucas Nussbaum
Subject: Re: strange expansion of <(cat p.main.{optional,extra})
Date: Wed, 18 Apr 2007 11:34:01 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

On 18/04/07 at 11:11 +0200, Andreas Schwab wrote:
> Chet Ramey <chet.ramey@case.edu> writes:
> 
> > lucas@lucas-nussbaum.net wrote:
> >
> >> Bash Version: 3.1
> >> Patch Level: 17
> >> Release Status: release
> >> 
> >> Description:
> >> Hi,
> >> 
> >> The expansion of echo <(cat /etc/{passwd,motd}) is rather surprising:
> >> $  echo <(cat p.main.{optional,extra})
> >> ++ cat p.main.optional
> >> cat: p.main.optional: No such file or directory
> >> ++ cat p.main.extra
> >> cat: p.main.extra: No such file or directory
> >> + echo /dev/fd/63 /dev/fd/62
> >> /dev/fd/63 /dev/fd/62
> >> 
> >> I would have expected to be expanded to <(cat /etc/passwd /etc/motd) first.
> >
> > That's not how it works.  Brace expansion is the first expansion performed.
> > The manual page says:
> >
> > "Brace expansion is performed before any other expansions, and any char-
> > acters special to other expansions are preserved in the result.  It  is
> > strictly  textual.  Bash does not apply any syntactic interpretation to
> > the context of the expansion or the text between the braces."
> 
> If it would be done strictly textual, the resulting expansion would
> actually be this:
> 
> $ echo <(cat p.main.optional) p.main.extra)
> 
> which would be a syntax error.

Well, no, because bash expands *parameters*, not words. So the prefix is
"<(cat /etc/", and the suffix is ")".
-- 
| Lucas Nussbaum
| lucas@lucas-nussbaum.net   http://www.lucas-nussbaum.net/ |
| jabber: lucas@nussbaum.fr             GPG: 1024D/023B3F4F |




reply via email to

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