From: Allan Poindexter <apoindex@aoc.nrao.edu>
To: zsh-workers@sunsite.auc.dk
Subject: order of processing in brace expansion
Date: 27 Apr 2001 11:31:48 -0600 [thread overview]
Message-ID: <yu9n1928d17.fsf@cato.aoc.nrao.edu> (raw)
Consider the following:
pts/11 10:37 208%setopt braceccl cato:/export/home/cato/apoindex
pts/11 10:38 209%foo=b,c cato:/export/home/cato/apoindex
pts/11 10:38 210%echo a{$foo}d cato:/export/home/cato/apoindex
a,d abd acd
pts/11 10:38 211%echo a{b,c}d cato:/export/home/cato/apoindex
abd acd
pts/11 10:38 212%unsetopt braceccl cato:/export/home/cato/apoindex
pts/11 10:38 213%echo a{$foo}d cato:/export/home/cato/apoindex
a{b,c}d
According to info:
Expansion is done in the above specified order in five steps. The
first is "history expansion" which is only performed in interactive
shells. The next step is "alias expansion" which is done right before
the command line is parsed. They are followed by "process
substitution", "parameter expansion", "command substitution",
"arithmetic expansion", and "brace expansion" which are performed in
one step in left-to-right fashion. After these expansions, all
unquoted occurrences of the characters `\', `'', and `"' are removed
and the result is subjected to "filename expansion" followed by
"filename generation".
Since brace expansion has syntactic markers at two points there is some
ambiguity about where it would fall in the left to right processing but it
seems that neither choice should cause the actual behavior seen.
If brace expansion is considered to occur at the opening brace then I would
expect:
%setopt braceccl
%echo a{$foo}d
a$d afd aod
%unsetopt braceccl
%echo a{$foo}d
ab,cd
in the above example since the brace expansion would occur before $foo was
parameter expanded.
If brace expansion is considered to occur at the closing brace then I would
expect:
%echo a{$foo}d
abd acd
since parameter expansion would occur first. (The setting of brace_ccl would
be unimportant in this case.)
What actually occurs seems to be that it is decided what kind of brace
expansion is needed at the opening brace but the brace expansion is actually
done (consistent with the decision of type made earlier) at the closing brace.
My personal preference would be for brace expansion to occur entirely at the
closing brace since that seems to me to be the most useful definition.
Perhaps others have a different view.
Can anyone shed any light on what I might be overlooking here?
/-\ |_ |_ /-\ |\|
next reply other threads:[~2001-04-27 17:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-27 17:31 Allan Poindexter [this message]
2001-04-27 18:09 ` Peter Stephenson
2001-04-28 6:05 ` Bart Schaefer
2001-04-28 18:17 ` Bart Schaefer
2001-05-02 9:50 ` Peter Stephenson
2001-05-02 14:59 ` Bart Schaefer
2001-05-02 15:28 ` Peter Stephenson
2001-05-02 16:30 ` Bart Schaefer
2001-05-09 9:06 ` Peter Stephenson
2001-05-11 16:57 ` Allan Poindexter
2001-05-11 19:22 ` Allan Poindexter
2001-05-11 20:09 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yu9n1928d17.fsf@cato.aoc.nrao.edu \
--to=apoindex@aoc.nrao.edu \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).