View Issue Details

IDProjectCategoryView StatusLast Update
00018211003.1(2016/18)/Issue7+TC2Shell and Utilitiespublic2024-07-24 14:34
Reportermortoneccc Assigned To 
PrioritynormalSeverityCommentTypeEnhancement Request
Status Interpretation RequiredResolutionAccepted As Marked 
NameEd Morton
Organization
User Reference
Sectionawk
Page Number0
Line Number0
Interp StatusApproved
Final Accepted Text0001821:0006781
Summary0001821: Define the values of $0, $1, etc. in the END section
DescriptionThe 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 ActionUpdate 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
---
Tagstc1-2024

Relationships

related to 0001823 Resolved The impact of changing NR and/or FNR should be defined 

Activities

geoffclare

2024-03-14 12:03

manager   bugnote:0006719

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.

geoffclare

2024-05-16 15:31

manager   bugnote:0006781

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.

agadmin

2024-06-21 11:48

administrator   bugnote:0006829

Interpretation proposed: 21 June 2024

agadmin

2024-07-24 14:34

administrator   bugnote:0006841

Last edited: 2024-07-25 03:59

Interpretation approved: 24 July 2024

Issue History

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