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: "K. Schreiner" <ks%ub.uni-mainz.de@localhost>
To: <gnats-bugs%NetBSD.org@localhost>
Cc: <kre%NetBSD.org@localhost>, <gnats-admin%netbsd.org@localhost>, <netbsd-bugs%netbsd.org@localhost>,
<paul%whooppee.com@localhost>
Subject: Re: bin/53507: awk doesn't properly compare "numeric strings"
Date: Wed, 8 Aug 2018 16:58:45 +0200
On Wed, Aug 08, 2018 at 10:30:01AM +0000, Robert Elz wrote:
> The following reply was made to PR bin/53507; it has been noted by GNATS.
>
> From: Robert Elz <kre%munnari.OZ.AU@localhost>
> To: gnats-bugs%NetBSD.org@localhost
> Cc:
> Subject: Re: bin/53507: awk doesn't properly compare "numeric strings"
> Date: Wed, 08 Aug 2018 17:24:42 +0700
>
> Date: Wed, 8 Aug 2018 09:30:02 +0000 (UTC)
> From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
> Message-ID: <20180808093002.4D38E7A1FA%mollari.NetBSD.org@localhost>
>
> | Check the definition of "numeric string".
>
> Yes, that is exactly right. This is not an awk bug [...]
>-6: uname -a
NetBSD nbt-8 7.99.18 NetBSD 7.99.18 (vNBx64) #3: Tue May 26 06:17:19 CEST 2015 ks@iws35-07:/u/NetBSD/arch/amd64/obj/sys/arch/amd64/compile/vNBx64 amd64
>-2: awk 'BEGIN { max="10"+0 ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
10
ok, if you want nummeric, add 0
>-3: awk 'BEGIN { max="10" ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
2
what others observed...
>-4: awk 'BEGIN { max="80" ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
9
hm, why 9? Maybe counts 0 to 8?
>-5: awk 'BEGIN { max="90" ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
90
And now? 90 is ok - or not?
Seems that 1-8 are "special" and 9 is handled as expectet?
FWIW: on an oldish Solaris-VM (SunOS ip8vms9 5.9 Generic_Virtual sun4v sparc sun4v)
>-269: which awk
/usr/xpg4/bin/awk
>-270: awk 'BEGIN { max="10" ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
10
>-271: /bin/awk 'BEGIN { max="10" ; for (i=0; i<max; i++) {print i}; exit}' | wc -l
2
and so on, same as on NetBSD above
Kurt
Home |
Main Index |
Thread Index |
Old Index