bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] NF variable's value is not affected after reassignment


From: Aharon Robbins
Subject: Re: [bug-gawk] NF variable's value is not affected after reassignment
Date: Sun, 22 Sep 2013 17:22:41 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hi.

Sorry for the delays in getting back to you on this.

I agree it's a bug. I have pushed a fix to the git repo, both in the
gawk-4.1-stable branch and in the master branch. You're using 4.0.1 which
is somewhat out of date.

Thanks for the report,

Arnold

> From: Wladimir Sidorenko <address@hidden>
> Date: Tue, 3 Sep 2013 12:45:31 +0200
> To: address@hidden
> Subject: [bug-gawk] NF variable's value is not affected after reassignment
>
> Dear members of the GNU Awk support team,
>
> Today, I've come across a somewhat unexpected behaviour of Gnu Awk. There,
> I assign a new value to the NF variable and after that I want to use this
> new value of NF in a for loop. But in contrast to the BSD awk and mawk,
> gawk seems to retain the initial value of NF in the loop.
>
> Here is an example:
>
> >echo 'aaa' | gawk '{NF = 10; for (j = 2; j <= NF; ++j){$j = "_"}; print;}'
> aaa _
>
> >echo 'aaa' | awk '{NF = 10; for (j = 2; j <= NF; ++j){$j = "_"}; print;}'
> aaa _ _ _ _ _ _ _ _ _
>
> >echo 'aaa' | mawk '{NF = 10; for (j = 2; j <= NF; ++j){$j = "_"}; print;}'
> aaa _ _ _ _ _ _ _ _ _
>
> >gawk --version
> GNU Awk 4.0.1
>
> >uname -srm
> NetBSD 6.1 amd64
>
> I could repeat the same difference on Linux 3.4.47-2.38-desktop x86_64
> (OpenSuSe).
>
> I send this to you for the case, that it could be a bug.
>
> Kind regards,
> Wladimir



reply via email to

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