The following issue has been SUBMITTED. ====================================================================== https://austingroupbugs.net/view.php?id=1785 ====================================================================== Reported By: kre Assigned To: ====================================================================== Project: Issue 8 drafts Issue ID: 1785 Category: Shell and Utilities Type: Error Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section: XCU 2.9.1.1 Page Number: 2483 Line Number: 80766-80778, 80790-80792 Final Accepted Text: ====================================================================== Date Submitted: 2023-10-28 04:09 UTC Last Modified: 2023-10-28 04:09 UTC ====================================================================== Summary: Conflict in specification of processing of declaration utilities Description: In XCU 2.9.1.1 bullet point 2, ut is said:
The first word (if any) that is not a variable assignment or redirection shall be expanded. If any fields remain following its expansion, the first field shall be considered the command name. If no fields remain, the next word (if any) shall be expanded, and so on, until a command name is found or no words remain. All that is fine and boring, then it continues: If there is a command name and it is recognized as a declaration utility, then any remaining words after the word that expanded to produce the command name, that would be recognized as a variable assignment in isolation, shall be expanded as a variable assignment [...] (it goes on to what all of that means, which is not important here). Note the required sequence, "the first word shall be expanded" ... [If there is one and] "it is recognised as a declaration utility" ... "shall be expanded as a variable assignment" ... There is nothing optional about what is specified there, first expand the word(s), then having found the command name, check if it (the result of the expansion) is a declaration utility, and if so do the special processing that is to be required of such things. But later, after the bullet points, at lines 80790-80792 (right at the bottom of page 2483) it says: When determining whether a command name is a declaration utility, an implementation may use only lexical analysis. That isn't what the previous text seems to require to me. It is unspecified whether assignment context will be used if the command name would only become recognized as a declaration utility after word expansions. To me, that looks to be very explicitly specified, as quoted above. Desired Action: Reconcile this nonsense. Best would be to delete the notion of "declaration utilities" completely, or at least make them optional (unspecified whether such things work). They're never needed, one can always simply write export FOO FOO=whatever-I-like and the assignment will be handled as a var-assign, without any magic special rules (those two statements can be written in either order, except for "readonly" where the assignment must come first), or if you prefer, the following also works FOO=whatever-I-like export FOO if you really need to do it all in one statement. This declaration utility nonsense (the special rules for arg processing) were added just to pacify people who don't understand the order in which the shell parses commands in general, and the syntax of the parts. What's more, including it, then leads to people wondering why (if we assume a file named "foo bar" (without the quotes) exists in '.' dd if=~/foo* ... or awk -v var=foo* ... aren't parsed the same way, after all, they look just the same, your average shell command line user has no idea what a "declaration utility" might be. Must easier to explain that the special rules for things which look like (and always are) var-assigns apply only to those which appear before the command name, as soon as there is anything (other than a redirect) all the special processing stops. But in any case, this "shall do ..." followed immediately by "may be done differently" needs to be fixed, one way or the other - either change bullet point 2 to make all of what it says about finding declaration utilities optional, or simply remove lines 90790-2, and require it to be implemented as in bullet point 2. [Aside: none of this means much to me, I have no intention of implementing "declaration utilities" whichever scheme were to be adopted.] ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2023-10-28 04:09 kre New Issue 2023-10-28 04:09 kre Name => Robert Elz 2023-10-28 04:09 kre Section => XCU 2.9.1.1 2023-10-28 04:09 kre Page Number => 2483 2023-10-28 04:09 kre Line Number => 80766-80778, 80790-80792 ======================================================================