(0006180)
kre (reporter)
2023-02-27 18:55
|
Yet another case where we would be far better off if the standard
had no aliases.
No surprise that no shells do what the text kind of looks like it
expects, as aliases would have been processed long before the
"command" command is executed - if one wanted to have "command"
apply to aliases (alias values) as well, one could do
alias command='command '
which would expand a following alias after command (as part of lexical
processing) if one appears there.
Without that, "command" is the word in the command word position, if that
is not an alias, no further words get checked to see if they are, until the
next command word position (which the following word is not, nor is it in
"exec word", xargs word, env word, ... though it can be in "eval word" as
that word is subject to lexical processing (to be tokenised).
The desired action is not adequate however, as it gives no clue what should
happen in the case in question. When the word after "command" is a function,
earlier text says what happens, but nothing does if it is an alias.
However, I agree that as long as aliases remain in POSIX, the text there
needs to be clearer.
I'd suggest something more like adding to the end of the sentence in
question
except that command_word does not appear in the command word
position in the command command, hence is not subject to alias or
reserved word lookups.
Note that command also suppresses reserved words, "command if ..." runs the
"if" command (from the filesystem, since command suppresses function lookups,
a function named "if" can't be run this way, even in shells that allow it to
be defined).
eg:
$ cat $HOME/bin/if
#! /bin/sh
echo If Only.
$ command if args are ignored in that script
If Only.
Every shell I tested behaves like that, as they all should. |
(0006203)
geoffclare (manager)
2023-03-13 15:52
edited on: 2023-03-13 15:56
|
After:If the command_name is the same as the name of one of the special built-in utilities, the special properties in the enumerated list at the beginning of Section 2.14 (on page 2384) shall not occur. In every other respect, if command_name is not the name of a function, the effect of command (with no options) shall be the same as omitting command . add:, except that command_name does not appear in the command word position in the command command, and consequently is not subject to alias substitution (see [xref to 2.3.1]) nor recognized as a reserved word (see [xref to 2.4]).
|