No, those are attempts at speed optimizations; the description before the 
numbered list of XCU 2.3 has line delimiting comes first as the logical model 
to determine tokenizing mode. This is continued in list items 4. and 5., that 
substitutions shall not occur during recognition. 

This makes it a requirement that a secondary pass, as the logical model, may be 
necessary to fully evaluate a token according to the grammar that applies for 
determining whether an alias name should be looked up. This model takes into 
account the result of a substitution may need to be classified as an assignment 
word or redirection when the grammar says a command prefix or keyword is the 
legal tokens, not a command or alias name only.

This isn't obvious, but there are many scripts that rely on $CC to provide the 
command name for a compiler, as an example. This can't be checked whether it 
holds an actual name until recognition of the line as a whole has been 
completed.
On Monday, April 20, 2020 Robert Elz <k...@munnari.oz.au> wrote:
    Date:        Mon, 20 Apr 2020 18:01:49 +0000 (UTC)
    From:        shwaresyst <shwares...@aol.com>
    Message-ID:  <1837359500.1041757.1587405709...@mail.yahoo.com>

  | It seems to me that what is missing, in XCU 2.3.1, is a statement that use
  | of keywords in alias bodies is unspecified behavior.

That isn't "missing" because it isn't unspecified.  What's more there is
no dispute at all that this works, and works in all shells.

  | Alias expansion occurs after this line is identified,

No, it doesn't.  It occurs immediately after a word has been recognised
in the command position - just the same as keyword recognition - and when
a previous alias expansion has caused the next word to be a potential alias.
Alias expansion (XCU 2.3.1) is in the Token recognition (XCU 2.3) section
of the standard for a reason, it is not a word expansion (XCU 2.6)).

But this is a general discussion of aliases, which is also not the point
of my query (unless this turns into a "remove aliases entirely" discussion)
which was very specific to alias recognition in command substitutions that
are quoted.

Joseph's message helps provide context, and it may be that now the
"historically shells have not done this" is nolonger true, and the
standard should revert to its earlier form.

kre

Reply via email to