[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange expansion of <(cat p.main.{optional,extra})
From: |
Andreas Schwab |
Subject: |
Re: strange expansion of <(cat p.main.{optional,extra}) |
Date: |
Wed, 18 Apr 2007 11:11:03 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux) |
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.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
- strange expansion of <(cat p.main.{optional,extra}), lucas, 2007/04/17
- Re: strange expansion of <(cat p.main.{optional,extra}), Chet Ramey, 2007/04/17
- Re: strange expansion of <(cat p.main.{optional,extra}),
Andreas Schwab <=
- Re: strange expansion of <(cat p.main.{optional,extra}), Lucas Nussbaum, 2007/04/18
- Re: strange expansion of <(cat p.main.{optional,extra}), Andreas Schwab, 2007/04/18
- Re: strange expansion of <(cat p.main.{optional,extra}), Eric Blake, 2007/04/18
- Re: strange expansion of <(cat p.main.{optional,extra}), Andreas Schwab, 2007/04/18
- Re: strange expansion of <(cat p.main.{optional,extra}), Lucas Nussbaum, 2007/04/18
Message not available