View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001821 | 1003.1(2016/18)/Issue7+TC2 | Shell and Utilities | public | 2024-03-14 11:42 | 2024-07-24 14:34 |
Reporter | mortoneccc | Assigned To | |||
Priority | normal | Severity | Comment | Type | Enhancement Request |
Status | Interpretation Required | Resolution | Accepted As Marked | ||
Name | Ed Morton | ||||
Organization | |||||
User Reference | |||||
Section | awk | ||||
Page Number | 0 | ||||
Line Number | 0 | ||||
Interp Status | Approved | ||||
Final Accepted Text | 0001821:0006781 | ||||
Summary | 0001821: Define the values of $0, $1, etc. in the END section | ||||
Description | The value of NF, i.e. the number of fields read, in the END section is defined in the standard as: --- Inside an END action, NF shall retain the value it had for the last record read --- but the value of $0, $1, and the other fields is not defined. Most modern awks will have them retain the value of the last record read, just like NF, but it is currently undefined behavior which seems like it's a simple omission from the spec. | ||||
Desired Action | Update the spec to say: --- Inside an END action, $0, $1, and the other fields shall retain the values they had for the last record read --- | ||||
Tags | tc1-2024 |
related to | 0001823 | Resolved | The impact of changing NR and/or FNR should be defined |
|
The suggested wording doesn't work for the NF=0 case. It needs to be something more like:Inside an END action, $0 and, if NF is greater than 0, the fields $1 through $NF shall retain the values they had for the last record read. |
|
Interpretation response ------------------------ The standard does not speak to this issue, and as such no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor. Rationale: ------------- The standard requires that the value of NF is retained in an END section, but does not state what the values of the fields $1 through $NF are, despite requiring them to exist. Notes to the Editor (not part of this interpretation): ------------------------------------------------------- Page and line numbers are for Issue 8 draft 4.1. At page 2614 line 85574 (FILENAME), delete: Inside an END action the value shall be the name of the last input file processed. At page 2614 line 85578 (FNR), change: Inside an END action the value shall be the number of the last record processed in the last file processed. to: If an application changes the value of FNR, the results are unspecified. At page 2614 line 85581 (NF), change: The number of fields in the current record. Inside a BEGIN action, the use of NF is undefined unless a getline function without a var argument is executed previously. Inside an END action, NF shall retain the value it had for the last record read, unless a subsequent, redirected, getline function without a var argument is performed prior to entering the END action. to: The number of fields in the current record. Inside the first BEGIN action, the value shall initially be zero, except that if the -v option was used to assign a value to NF it is unspecified whether that value is retained or the value is reset to zero. At page 2614 line 85587 (NR), change: Inside an END action the value shall be the number of the last record processed. to: If an application changes the value of NR, the results are unspecified. At page 2618 after line 85708 (Special Patterns), add: Entering an END action shall not alter the value of any fields or variables that had previously been set. |
|
Interpretation proposed: 21 June 2024 |
|
Interpretation approved: 24 July 2024 |
Date Modified | Username | Field | Change |
---|---|---|---|
2024-03-14 11:42 | mortoneccc | New Issue | |
2024-03-14 11:42 | mortoneccc | Name | => Ed Morton |
2024-03-14 11:42 | mortoneccc | Section | => awk |
2024-03-14 11:42 | mortoneccc | Page Number | => 0 |
2024-03-14 11:42 | mortoneccc | Line Number | => 0 |
2024-03-14 12:03 | geoffclare | Note Added: 0006719 | |
2024-05-16 15:31 | geoffclare | Note Added: 0006781 | |
2024-05-16 15:33 | geoffclare | Interp Status | => Pending |
2024-05-16 15:33 | geoffclare | Final Accepted Text | => 0001821:0006781 |
2024-05-16 15:33 | geoffclare | Status | New => Interpretation Required |
2024-05-16 15:33 | geoffclare | Resolution | Open => Accepted As Marked |
2024-05-16 15:33 | geoffclare | Tag Attached: tc1-2024 | |
2024-05-16 15:54 | eblake | Relationship added | related to 0001823 |
2024-06-21 11:48 | agadmin | Interp Status | Pending => Proposed |
2024-06-21 11:48 | agadmin | Note Added: 0006829 | |
2024-07-24 14:34 | agadmin | Interp Status | Proposed => Approved |
2024-07-24 14:34 | agadmin | Note Added: 0006841 | |
2024-07-25 03:59 | agadmin | Note Edited: 0006841 |