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
>Organization:
+------------------+--------------------------+----------------------------+
| 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 |
+------------------+--------------------------+----------------------------+
>Environment:
	
	
System: NetBSD speedy.whooppee.com 8.99.22 NetBSD 8.99.22 (SPEEDY 2018-07-25 07:42:52 UTC) #0: Wed Jul 25 13:38:00 UTC 2018 paul%speedy.whooppee.com@localhost:/build/netbsd-local/obj/amd64/sys/arch/amd64/compile/SPEEDY amd64
Architecture: x86_64
Machine: amd64
>Description:
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/makesyscalls.sh script.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06
	
>How-To-Repeat:
See above.
	
>Fix:
Unknown.
	

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index