A NOTE has been added to this issue. ====================================================================== https://austingroupbugs.net/view.php?id=1778 ====================================================================== Reported By: kre Assigned To: ====================================================================== Project: Issue 8 drafts 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 Final Accepted Text: ====================================================================== Date Submitted: 2023-10-02 13:58 UTC Last Modified: 2023-11-27 17:29 UTC ====================================================================== Summary: The read utility needs field splitting updates/corrections )and a little more) ====================================================================== Relationships ID Summary ---------------------------------------------------------------------- related to 0001649 Field splitting is woefully under speci... ======================================================================
---------------------------------------------------------------------- (0006592) nick (manager) - 2023-11-27 17:29 https://austingroupbugs.net/view.php?id=1778#c6592 ---------------------------------------------------------------------- On page 3291 line 111859 section read, change: <blockquote>By default, unless the <b>-r</b> option is specified, <backslash> shall act as an escape character. An unescaped <backslash> shall preserve the literal value of the following character, with the exception of ...</blockquote> to: <blockquote>If the <b>-r</b> option is not specified, <backslash> shall act as an escape character. An unescaped <backslash> shall preserve the literal value of a following <backslash> and shall prevent a following byte (if any) from being used to split fields, with the exception of ...</blockquote> On page 3291 line 111869 section read, replace the paragraph beginning <blockquote>The terminating logical line delimiter</blockquote> 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 variable <i>IFS</i> (see [xref XCU 2.5.3]) is set, and its value is an empty string, the resulting data shall be assigned to the variable named by the first <i>var</i> operand, and the variables named by other <i>var</i> operands (if any) shall be set to the empty string. No other processing shall be performed in this case. 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 logical line (minus terminating delimiter) that was read from standard input, and shall be considered as a single initial field, all of which resulted from expansions, with any escaped byte and the preceding <backslash> escape character treated as if they were the result of a quoted expansion, and all other bytes treated as if they were the results of unquoted expansions.</li> <li>The loop over the contents of that initial field shall cease when either the input is empty or <i>n</i> output fields have been generated, where <i>n</i> is one less than the number of <i>var</i> operands passed to the <i>read</i> utility. Any remaining input in the original field being processed shall be returned to the <i>read</i> utility ``unsplit''; that is, unmodified except that any leading or trailing <i>IFS</i> white space, as defined in [xref to XCU 2.6.5], shall be removed.</li> </ol> The specified <i>var</i> operands shall be processed in the order they appear on the command line, and the output fields generated by the field splitting algorithm shall be used in the order they were generated, by repeating the following checks until neither is true: <ul> <li>If more than one <i>var</i> operand is yet to be processed and one or more output fields are yet to be used, the variable named by the first unprocessed <i>var</i> operand shall be assigned the value of the first unused output field.</li> <li>If exactly one <i>var</i> operand is yet to be processed and there was some remaining unsplit input returned from the modified field splitting algorithm, the variable named by the unprocessed <i>var</i> operand shall be assigned the unsplit input.</li> </ul> If there are still one or more unprocessed <i>var</i> operands, each of the variables names by those operands shall be assigned an empty string. Note that in the case where just one <i>var</i> operand is given on the <i>read</i> command line, the modified field splitting algorithm ceases after producing zero output fields and simply returns the original input field, with any leading and trailing <i>IFS</i> white space removed, as unsplit input. This unsplit input is assigned to the variable named by the <i>var</i> operand.</blockquote> On page 3292 line 111900 section read (OPERANDS), after: <blockquote>The name of an existing or nonexisting shell variable.</blockquote> append: <blockquote>If a <i>var</i> operand names the variable <i>IFS</i>, the behavior is unspecified. If a <i>var</i> operand names one of the variables <i>LANG</i>, <i>LC_CTYPE</i>, or <i>LC_ALL</i> and the new value assigned to the variable would change how the bytes in <i>IFS</i> form characters, or which characters in <i>IFS</i> are considered to be <i>IFS</i> white space (see [xref XCU 2.6.5]), it is unspecified what effects, if any, the change has on how <i>read</i> performs field splitting.</blockquote> On page 3292 line 111902 section read (STDIN), change: <blockquote>If the <b>-d</b> <i>delim</i> option is not specified, or if it is specified and <i>delim</i> consists of one single-byte character, the standard input shall contain zero or more characters and shall not contain any null bytes.</blockquote> to: <blockquote>If the <b>-d</b> <i>delim</i> option is not specified, or if it is specified and <i>delim</i> is not the null string, the standard input shall contain zero or more bytes (which need not form valid characters) and shall not contain any null bytes.</blockquote> On page 3293 line 111959 section read (APPLICATION USAGE), change: <blockquote>When the current locale is not the C or POSIX locale, pathnames can contain bytes that do not form part of a valid character, and therefore portable applications need to ensure that the current locale is the C or POSIX locale when using read with arbitrary pathnames as input. (If <i>IFS</i> is not set to the null string this applies even when using <b>-d</b> "", because the field splitting performed by read is a character-based operation.) When reading a pathname it is also inadvisable ...</blockquote> to: <blockquote>When reading a pathname it is inadvisable ...</blockquote> After page 3293 line 111967 section read (APPLICATION USAGE), add: <blockquote>Since the <i>var</i> operands are processed in the order specified on the command line, if any variable name is specified more than once as a <i>var</i> operand, the last assignment made is the one that is in effect when <i>read</i> returns, including when an empty string is assigned because no field data was available.</blockquote> </blockquote> On page 3293, lines 111979-111980, change: <blockquote>Since read affects the current shell execution environment, it is generally provided as a shell |regular built-in.</blockquote> to: <blockquote>Since read affects the current shell execution environment, it is required to be intrinsic.</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 2023-10-02 14:02 kre Note Edited: 0006500 2023-10-02 14:20 kre Note Added: 0006502 2023-10-02 14:22 kre Note Edited: 0006502 2023-10-02 14:24 kre Note Edited: 0006502 2023-10-02 14:30 kre Note Added: 0006503 2023-10-02 14:33 kre Note Edited: 0006502 2023-10-02 14:34 kre Note Edited: 0006502 2023-10-02 14:44 kre Note Edited: 0006500 2023-10-02 16:18 geoffclare Project 1003.1(2013)/Issue7+TC1 => Issue 8 drafts 2023-10-02 16:19 geoffclare version => Draft 3 2023-10-02 16:20 geoffclare Note Added: 0006507 2023-10-02 16:21 geoffclare Relationship added related to 0001649 2023-10-03 09:23 geoffclare Note Added: 0006509 2023-10-03 11:59 kre Note Added: 0006510 2023-10-03 12:11 kre Note Added: 0006511 2023-10-03 13:42 geoffclare Note Added: 0006512 2023-10-04 14:42 kre Note Added: 0006513 2023-10-04 17:36 kre Note Added: 0006514 2023-10-05 08:59 geoffclare Note Added: 0006515 2023-10-05 11:08 kre Note Added: 0006516 2023-10-05 14:53 geoffclare Note Added: 0006517 2023-10-05 15:34 kre Note Edited: 0006516 2023-10-05 15:35 kre Note Edited: 0006516 2023-10-05 15:36 kre Note Edited: 0006516 2023-10-05 15:38 kre Note Added: 0006519 2023-10-05 15:41 kre Note Edited: 0006513 2023-10-06 07:58 geoffclare Note Edited: 0006515 2023-10-06 21:41 chet_ramey Note Added: 0006524 2023-10-10 11:06 geoffclare Note Edited: 0006515 2023-10-10 14:36 geoffclare Note Added: 0006526 2023-10-10 17:19 kre Note Added: 0006527 2023-10-11 08:04 geoffclare Note Added: 0006528 2023-10-11 17:13 kre Note Added: 0006529 2023-10-12 08:30 geoffclare Note Added: 0006530 2023-10-12 18:33 kre Note Added: 0006531 2023-10-12 18:45 kre Note Edited: 0006516 2023-10-12 18:54 kre Note Added: 0006532 2023-10-16 09:02 geoffclare Note Added: 0006533 2023-10-16 09:03 geoffclare Note Edited: 0006533 2023-10-16 09:19 geoffclare Note Added: 0006534 2023-10-16 21:43 kre Note Added: 0006537 2023-10-16 22:10 kre Note Added: 0006538 2023-10-17 13:34 geoffclare Note Added: 0006543 2023-10-18 00:08 kre Note Added: 0006547 2023-10-19 14:05 geoffclare Note Added: 0006548 2023-10-19 16:33 kre Note Added: 0006550 2023-10-19 16:37 kre Note Edited: 0006550 2023-11-27 17:29 nick Note Added: 0006592 ======================================================================