NetBSD-Bugs archive

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

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



The following reply was made to PR bin/53507; it has been noted by GNATS.

From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/53507: awk doesn't properly compare "numeric strings"
Date: Wed, 8 Aug 2018 12:29:28 +0300

 On Wed, Aug 08, 2018 at 12:20:18 +0300, Valery Ushakov wrote:
 
 > On Wed, Aug 08, 2018 at 03:20:01 +0000, paul%whooppee.com@localhost wrote:
 > 
 > > As an example,
 > > 
 > > 	awk 'BEGIN { max="10" ; for (i=0; i<max; i++) {print i}; exit}'
 > >
 > [uwe: fixed typo in example]
 > > 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.
 > 
 > Just a quick note that both mawk and gawk behave the same.
 
 Ah, right, skimming the manual I remember now.  Check the definition
 of "numeric string".  In your example max = "10" is not a numeric
 string since it's an explicit assignment.  The reasoning is that if
 you wanted it to be a number, you would have written it as a number.
 
 -uwe
 


Home | Main Index | Thread Index | Old Index