A NOTE has been added to this issue. ====================================================================== https://www.austingroupbugs.net/view.php?id=1778 ====================================================================== Reported By: kre Assigned To: ====================================================================== Project: 1003.1(2013)/Issue7+TC1 Issue ID: 1778 Category: Shell and Utilities Type: Enhancement Request Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section: XCU 3/read Page Number: 3291-3294 Line Number: 111869-111878, 111961-111963, 11946, 11979-11980 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2023-10-02 13:58 UTC Last Modified: 2023-10-02 14:00 UTC ====================================================================== Summary: The read utility needs field splitting updates/corrections )and a little more) ======================================================================
---------------------------------------------------------------------- (0006500) kre (reporter) - 2023-10-02 14:00 https://www.austingroupbugs.net/view.php?id=1778#c6500 ---------------------------------------------------------------------- Replace the paragraph beginning <blockquote>The terminating logical line delimiter</blockquote> at line 11869, and continuing down past the three bullet points to line 11878 (inclusive) with the following: <blockquote>The terminating logical line delimiter (if any) shall be removed from the input. Then if the shell <i>IFS</i> variable [xref XCU 2.5.3] is set, and its value is an empty string, the resulting data shall be assigned to the first variable <i>var</i> named upon the command line, with any other variables named being set to the empty string. No other processing takes place. </blockquote> <blockquote>If <i>IFS</i> is unset, or is set to any non-empty value, then a modified version of the field splitting algorithm specified in [xref XCU 2.6.5] shall be applied, with the modifications as follows: <ol><li>The input to the algorithm shall be the result obtained from the <b>read</b>, and shall be considered as a single initial field, all of which resulted from an expansion.</li> <li>The loop over the contents of that field shall cease when either the input is empty, or when <i>n</i> output fields have been generated, where <i>n</n> is one less than the number of variable name arguments to the <b>read</b> command. Any remaining input in the original field being processed shall be returned to the read command, unmodified, except that any leading or trailing IFS white space, as defined in XCU 2.6.5, shall be removed.</li></ol></blockquote> <blockquote>The number of output fields generated by the field splitting algorithm shall be called <i>m</i>. The first <i>m</i> (which must be less than or equal to <i>n</i>) variables named upon the <b>read</b> command line are assigned the values from the ordered list of output fields, in the order they were generated, starting with the first variable names, and continuing until <i>m</i> variables have had values assigned. If <i>m</i> = <i>n</i> then the remaining unsplit input returned from the modified field splitting algorithm shall be assigned to the <i>n</i>+1'st variable named upon the command line. Any later variables to which no value has been assigned shall be assigned an empty string.</blockquote> <blockquote>Note that in the case where just one variable name was given on the read command line, the algorithm in XCU 2.6.5 ceases after producing zero (<i>m</i>) output fields, and simply returns the input field with any leading and trailing <i>IFS</i> white space removed. No output fields exist to assign to variables, so the remaining modified input is assigned to the first (and only) variable named.</blockquote> In addition to this, somewhere we should probably also add either: <blockquote>If any variable name is specified more than once as an argument to <b>read</b> the results are unspecified.</blockquote> or, as all shells seem to implement it this way, even though it doesn't seem even vaguely useful to me: <blockquote>If any variable name is specified more than once as an argument to <b>read</b> then the values are assigned in order as specified above, with any later assignment replacing the earlier, including when an empty string is assigned because no field data was available.</blockquote> Issue History Date Modified Username Field Change ====================================================================== 2023-10-02 13:58 kre New Issue 2023-10-02 13:58 kre Name => Robert Elz 2023-10-02 13:58 kre Section => XCU 3/read 2023-10-02 13:58 kre Page Number => 3291-3294 2023-10-02 13:58 kre Line Number => 111869-111878, 111961-111963, 11946, 11979-11980 2023-10-02 14:00 kre Note Added: 0006500 ======================================================================
