Anonymous | Login | 2023-11-29 18:50 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 | ||
0001198 | [1003.1(2016/18)/Issue7+TC2] Shell and Utilities | Objection | Error | 2018-08-07 10:40 | 2019-11-12 15:08 | ||
Reporter | geoffclare | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted As Marked | ||||
Status | Applied | ||||||
Name | Geoff Clare | ||||||
Organization | The Open Group | ||||||
User Reference | |||||||
Section | awk | ||||||
Page Number | 2489 | ||||||
Line Number | 80031 | ||||||
Interp Status | Approved | ||||||
Final Accepted Text | See Note: 0004320. | ||||||
Summary | 0001198: Comparison of numeric string values in awk | ||||||
Description |
[The following was reported to The Open Group help desk.] The "Expressions In Awk" section of the standard says: --- Comparisons (with the '<', "<=", "!=", "==", '>', and ">=" operators) shall be made numerically if both operands are numeric, if one is numeric and the other has a string value that is a numeric string, or if one is numeric and the other has the uninitialized value. Otherwise, operands shall be converted to strings as required and a string comparison shall be made --- That's means that when a comparison involves 2 numeric strings it is a string comparison but of course in reality in all awks it is treated as a numeric comparison so that, for example, this: echo '5.0 10.0' | awk '$1 < $2' evaluates to true rather than false. There are some other confusing/misleading statements (at best) in the standard around the type of input fields and their value that could be written far more clearly - see https://groups.google.com/d/msg/comp.lang.awk/qYhgpz08pN8/9wbMr9XKCQAJ [^] and https://stackoverflow.com/q/51632945/1745001 [^] for discussions that have taken place recently on different forums around this area. [The comp.lang.awk discussion also talks about uninitialized fields behaving differently than uninitialized variables in some awks when compared to 0, but I think the standard is clear and intends what it says, so this is simply non-conforming behaviour in those awks. I think it is certainly undesirable for uninitialized fields to behave differently than uninitialized variables.] [The stackoverflow.com discussion is also about uninitialized fields but includes an answer which points out that the expressions table has this entry: Syntax | Name | Type of Result | Associativity $expr | Field reference | String | N/A which conflicts with the descriptive text in that it implies field variables always yield string values when used in an expression.] |
||||||
Desired Action |
On page 2489 line 80031 section awk change:... shall be made numerically if both operands are numeric, ...to: ... shall be made numerically if both operands are numeric, if both have string values that are numeric strings, ... On page 2485 line 79876 section awk change: $expr | Field reference | String | N/Ato: $expr | Field reference | Uninitialized or string | N/A |
||||||
Tags | tc3-2008 | ||||||
Attached Files | |||||||
|
![]() |
|||
Date Modified | Username | Field | Change |
2018-08-07 10:40 | geoffclare | New Issue | |
2018-08-07 10:40 | geoffclare | Name | => Geoff Clare |
2018-08-07 10:40 | geoffclare | Organization | => The Open Group |
2018-08-07 10:40 | geoffclare | Section | => awk |
2018-08-07 10:40 | geoffclare | Page Number | => 2489 |
2018-08-07 10:40 | geoffclare | Line Number | => 80031 |
2018-08-07 10:40 | geoffclare | Interp Status | => --- |
2019-03-14 15:45 | Don Cragun | Note Added: 0004320 | |
2019-03-14 15:46 | Don Cragun | Final Accepted Text | => See Note: 0004320. |
2019-03-14 15:46 | Don Cragun | Status | New => Interpretation Required |
2019-03-14 15:46 | Don Cragun | Resolution | Open => Accepted As Marked |
2019-03-14 15:46 | Don Cragun | Description Updated | |
2019-03-14 15:46 | Don Cragun | Tag Attached: tc3-2008 | |
2019-03-14 15:55 | Don Cragun | Note Edited: 0004320 | |
2019-03-16 06:32 | agadmin | Interp Status | --- => Proposed |
2019-03-16 06:32 | agadmin | Note Added: 0004325 | |
2019-04-17 10:52 | agadmin | Interp Status | Proposed => Approved |
2019-04-17 10:52 | agadmin | Note Added: 0004369 | |
2019-11-12 15:08 | geoffclare | Status | Interpretation Required => Applied |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |