bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Gawk Bug in arrays?


From: Aharon Robbins
Subject: Re: Gawk Bug in arrays?
Date: Sun, 07 Nov 2010 20:37:46 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hi. Thanks for your note. As already mentioned, the behavior you discovered
is not intuitive, but it is nontheless the defined, standardized, and
historical behavior for awk.  It can't be changed now.

Thanks,

Arnold

> Date: Fri, 5 Nov 2010 12:11:44 -0700 (PDT)
> From: address@hidden
> Subject: Gawk Bug in arrays?
> To: address@hidden
>
> Hi, I'm using Gawk 3.1.8, and if I run this:
>
> BEGIN {
> ??? a[1] = "hi"
> ??? if ( a[2] != "" ) print a[2]
> ??? for ( inx in a )
> ??? {
> ??????? print inx " " a[inx]
> ??? }
> }
>
> I get:
>
> bash-3.2$ gawk -f awkhate.awk
> 1 hi
> 2
> bash-3.2$
>
> The act of comparing a[2] (which should not exist) sets it to "".? I was 
> mistakenly using this instead of a preferred:
> if ( 2 in a )
>
> However, I don't think that it should have behaved this way, regardless.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]