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 _ _ _ _ _ _ _ _ _
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.