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

2007-04-17 Thread lucas
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2
uname output: Linux beothuk.imag.fr 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 
2007 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

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.

Repeat-By:
echo <(cat /etc/passwd /etc/motd)

tested with bash 3.1 and 3.2. Someone else told me on IRC that 2.05 was also 
affected.

Lucas.


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


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

2007-04-18 Thread Lucas Nussbaum
On 18/04/07 at 11:11 +0200, Andreas Schwab wrote:
> Chet Ramey <[EMAIL PROTECTED]> writes:
> 
> > [EMAIL PROTECTED] 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
| [EMAIL PROTECTED]   http://www.lucas-nussbaum.net/ |
| jabber: [EMAIL PROTECTED] GPG: 1024D/023B3F4F |


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


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

2007-04-18 Thread Lucas Nussbaum
On 18/04/07 at 14:37 +0200, Andreas Schwab wrote:
> Eric Blake <[EMAIL PROTECTED]> writes:
> 
> > According to Andreas Schwab on 4/18/2007 4:01 AM:
> >> Lucas Nussbaum <[EMAIL PROTECTED]> writes:
> >> 
> >>> Well, no, because bash expands *parameters*, not words. So the prefix is
> >>> "<(cat /etc/", and the suffix is ")".
> >> 
> >> But that would not be a *strict textual* expansion.
> >
> > According to 'man bash', brace expansion is documented as being able to
> > expand one word into many.
> 
> The documentation talks about strings, not words.

Based on the behaviour, I think that bash first splits the command line
into a list of parameters, then expands each parameter. <(...) is a
single parameter.
-- 
| Lucas Nussbaum
| [EMAIL PROTECTED]   http://www.lucas-nussbaum.net/ |
| jabber: [EMAIL PROTECTED] GPG: 1024D/023B3F4F |


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash