NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/53507: awk doesn't properly compare "numeric strings"

>Number:         53507
>Category:       bin
>Synopsis:       awk doesn't properly compare "numeric strings"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 08 03:20:01 +0000 2018
>Originator:     Paul Goyette
>Release:        NetBSD 8.99.22
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
System: NetBSD 8.99.22 NetBSD 8.99.22 (SPEEDY 2018-07-25 07:42:52 UTC) #0: Wed Jul 25 13:38:00 UTC 2018 amd64
Architecture: x86_64
Machine: amd64
According to the posix man-page[1] for awk, 

	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,
	if one is numeric and the other has the uninitialized value.  ...

However, we are not doing this.  As an example,

	awk 'BEGIN { max="10" ; for (i=0; i<max, i++) {print i}; exit}'

will only print the values 0 and 1, even though the assignment for max
seems to meet the definition of "numeric string" as contained in the
referenced man-page.

Among other things, this can affect the proper operation of the awk
program contained in the sys/kern/ script.

See above.


Home | Main Index | Thread Index | Old Index