bug-bash
[Top][All Lists]
Advanced

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

Re: Brace expansion ordering vs. parameter expansion


From: Chet Ramey
Subject: Re: Brace expansion ordering vs. parameter expansion
Date: Thu, 29 Apr 2021 10:45:47 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1

On 4/29/21 8:12 AM, Ilkka Virta wrote:

    Maybe, but it's never worked that way and was never intended to. You can
    get what you need using eval:

    eval echo \{1..${i}}


BTW, was there some background to why they're ordered like this? I'm not sure if I have heard the story, and didn't see anything about it in Greg's wiki or bash-hackers.org <http://bash-hackers.org> (of course they tell the "what", but not the "why"). I didn't dig through all the mailing lists, though.

Here's something I wrote in response to another message:

=====
OK. Bash has had brace expansion in essentially its current form since
1991, and we chose the implementation we did with an eye towards making
the code something that other applications could just pick up and
incorporate. Korn chose to perform brace expansion as a component of
filename expansion (globbing), which happens after the other word
expansions. I'm sure he thought it was better, but he chose not to be
compatible with bash.
=====

I wrote 1991, but it was actually early 1989 when we (Brian and I) wrote
the brace expansion code and put it in. We decided early on to make brace
expansion independent of filename expansion, so you could have brace
expansion even after performing `set -f'. There was thought towards making
the brace expansion code reusable, in the sense that other GNU tools could
take the code and easily add it to their argument processing. We were also
reluctant to change the filename expansion code, which, at the time, we
shared with other GNU applications including emacs.

So we made brace expansion a separate step, one that could be enabled and
disabled independent of other expansions, with a defined input and output
format, and made it happen before the POSIX word expansions. And here we
are, thirty-plus years later.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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