Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001637 [1003.1(2016/18)/Issue7+TC2] Shell and Utilities Objection Clarification Requested 2023-02-27 17:17 2024-06-11 09:07
Reporter nick View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Nick Stoughton
Organization Logitech
User Reference
Section command
Page Number 2596
Line Number 84263-84266
Interp Status ---
Final Accepted Text Note: 0006203
Summary 0001637: The command utility does not execute aliases
Description The description of command with no options given states:

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.

This suggests that
alias x=ls
command x

should run the alias "x". No existing shell or implementation of the "command" utility I have found does this, but instead says that "x is not found" (in some form).
Desired Action In D2.1, page 2553, line 83836, change

... if command_name is not the name of a function,

to

... if command_name is not the name of a function or alias,
Tags applied_after_i8d3, tc3-2008
Attached Files

- Relationships

-  Notes
(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]).



- Issue History
Date Modified Username Field Change
2023-02-27 17:17 nick New Issue
2023-02-27 17:17 nick Name => Nick Stoughton
2023-02-27 17:17 nick Organization => Logitech
2023-02-27 17:17 nick Section => command
2023-02-27 17:17 nick Page Number => 2596
2023-02-27 17:17 nick Line Number => 84263-84266
2023-02-27 17:17 nick Interp Status => ---
2023-02-27 17:17 nick Category System Interfaces => Shell and Utilities
2023-02-27 18:55 kre Note Added: 0006180
2023-03-13 15:52 geoffclare Note Added: 0006203
2023-03-13 15:53 geoffclare Final Accepted Text => Note: 0006203
2023-03-13 15:53 geoffclare Status New => Resolved
2023-03-13 15:53 geoffclare Resolution Open => Accepted As Marked
2023-03-13 15:53 geoffclare Tag Attached: tc3-2008
2023-03-13 15:56 geoffclare Note Edited: 0006203
2023-05-16 11:04 geoffclare Status Resolved => Applied
2023-05-16 11:04 geoffclare Tag Attached: applied_after_i8d3
2024-06-11 09:07 agadmin Status Applied => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker