Anonymous | Login | 2024-09-16 22:44 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||||||||
0001853 | [1003.1(2024)/Issue8] Shell and Utilities | Objection | Clarification Requested | 2024-09-02 14:27 | 2024-09-05 15:22 | ||||||||
Reporter | geoffclare | View Status | public | ||||||||||
Assigned To | |||||||||||||
Priority | normal | Resolution | Accepted | ||||||||||
Status | Resolved | ||||||||||||
Name | Geoff Clare | ||||||||||||
Organization | The Open Group | ||||||||||||
User Reference | |||||||||||||
Section | xargs | ||||||||||||
Page Number | 3602 | ||||||||||||
Line Number | 123241 | ||||||||||||
Interp Status | --- | ||||||||||||
Final Accepted Text | |||||||||||||
Summary | 0001853: xargs -x lost an important detail between Issue 6 and 7 | ||||||||||||
Description |
In Issue 6 the description of xargs -x was:Terminate if a command line containing number arguments (see the -n option above) [XSI] or number lines (see the -L option above) [/XSI] will not fit in the implied or specified size (see the -s option above). In Issue 7 it became: Terminate if a constructed command line will not fit in the implied or specified size (see the -s option above). An important feature of the Issue 6 text was that if you specify, say, -n 2 in order to process input arguments in pairs, and there is a pair of arguments for which the constructed command will not fit, then without -x xargs would execute a command with only one argument, whereas with -x it will terminate. The new text allows xargs to execute a command with only one argument regardless of whether -x is specified. I have tracked down the source of the change to XCU ERN 68 in https://www.opengroup.org/austin/aardvark/latest/xcubug2.txt [^] The relevant part of the problem statement is: 2. (objection) The synopsis shows that the -x option can only be used with the -n option, but the options section indicates that it can be used both with -n and -L and is forced on with -I. It also indicates that -x interacts with the size specified by a -s option or by the default command line size if the -s option is not specified. In fact, with sufficiently long arguments on the xargs command line, the -x option is needed even when -I, -L, -n, and -s are not specified. Existing practice seems to be that -x is not tied to any of these options and should be available no matter what other options are specified. Clearly there was no intention to alter the behaviour when -x is used with -n. The desire was to clarify its use without -n. Unfortunately, the side-effect on -n of simplifying the text was not noticed. Also, the final sentence quoted above is not true for some systems: macOS and FreeBSD (and presumably other BSDs) only accept -x with -n. Although -x is accepted on many systems independently of other options, it is not clear what effect it is supposed to have if none of -n, -L, or -I is specified. The current description "Terminate if a constructed command line will not fit in the implied or specified size (see the -s option above)" just appears to state something that xargs should do regardless of whether -x is specified. I.e. if a command that uses only the next argument from the input won't fit, then xargs should report an error. On Solaris -x is a no-op if neither -n nor -L is not specified. It's possible that the original source of the confusion is the statement for -I that "Option -x shall be forced on." This was always meaningless and unnecessary, and trying to read meaning into it could have led to misinterpreting what the purpose of -x is. The purpose of -x is illustrated in example 2 in the standard (which shows how to use xargs to invoke diff with successive pairs of arguments). My proposed wording changes only require that systems accept -x when either -n or -L is also used (so that macOS and the BSDs don't need to accept -x with other options in order to conform). This means applications can no longer portably specify -x and -I together, but since -x is required to be a no-op when used with -I it seems highly unlikely that any application does this. In any case, the combination will undoubtedly continue to be accepted on implementations that already accept it. Finally, the new text for -x misuses the word "constructed". The first paragraph of the DESCRIPTION says that xargs "shall construct a command line consisting of the utility and argument operands specified followed by as many arguments read in sequence from standard input as fit in length and number constraints specified by the options". Thus constructed command lines always fit. Instead of "if a constructed command line will not fit", the -x text should say "if a command line that will fit cannot be constructed". |
||||||||||||
Desired Action |
On page 3600 line 123148 section xargs (SYNOPSIS), change:xargs [-prtx] [-E eofstr|-0] [<XSI>-I replstr|-L number</XSI>| -n number] to: xargs [-prt] [-E eofstr|-0] [<XSI>-I replstr|-L number [-x]|</XSI >-n number [-x]] After page 3600 line 123162 section xargs (DESCRIPTION), add a paragraph: Each constructed command line shall include at least one argument from standard input. It shall be an error if a command line that will fit in the implied or specified size (see the -s option) cannot be constructed containing even one argument. On page 3601 line 123206 section xargs (OPTIONS, -I), delete: Option -x shall be forced on. On page 3602 line 123241 section xargs (OPTIONS, -x), change: Terminate if a constructed command line will not fit in the implied or specified size (see the -s option above). to: Terminate if a command line containing number arguments (see the -n option) <XSI>or number lines (see the -L option)</XSI> that will fit in the implied or specified size (see the -s option) cannot be constructed. Applications should use the -x option when it would not be appropriate for constructed commands to contain fewer than number arguments; for example, when executing the diff utility with -n 2 in order to compare pairs of files. After page 3605 line 123412 section xargs (RATIONALE), add a paragraph: Editions of this standard between 2008 and 2024 did not require xargs to terminate if -x and -n number were both specified and a command line containing number arguments could not be constructed. This requirement was unintentionally lost while simplifying the description of -x. These editions continued to show (in EXAMPLES) the use of -x to force all executions of diff to be passed two operands. The requirement has now been reinstated. In addition, prior to 2008 it was unclear whether conforming XSI implementations were required to accept -x with -L number (because although this combination was described in the text, the SYNOPSIS did not require it to be accepted). Editions between 2008 and 2024 required the combination to be accepted, but with the same defect as for -x -n number. The requirements for -L now match those for -n. Some implementations accept -x with other options besides -n and -L, but there is no reason for portable applications to use such combinations and this standard does not require them to be accepted. |
||||||||||||
Tags | tc1-2024 | ||||||||||||
Attached Files | |||||||||||||
|
Notes | |
(0006868) geoffclare (manager) 2024-09-02 14:31 |
Note that the spurious newlines in the SYNOPSIS change are a Mantis artifact. |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |