Subject: bin/29659: awk handling of END non-portable
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <he@netbsd.org>
List: netbsd-bugs
Date: 03/11/2005 15:43:00
>Number: 29659
>Category: bin
>Synopsis: awk handling of END non-portable
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 11 15:43:00 +0000 2005
>Originator: Havard Eidnes
>Release: NetBSD 2.0
>Organization:
>Environment:
System: NetBSD quattro.urc.uninett.no 2.0 NetBSD 2.0 (GENERIC.MP) #0: Wed Dec 1 11:06:48 UTC 2004 builds@build:/big/builds/ab/netbsd-2-0-RELEASE/i386/200411300000Z-obj/big/builds/ab/netbsd-2-0-RELEASE/src/sys/arch/i386/compile/GENERIC.MP i386
Architecture: i386
Machine: i386
>Description:
On NetBSD 2.0 and -current, this command line:
echo hi | awk 'END { print }'
prints an empty line, and not the last line of the input.
On NetBSD 1.6.2_STABLE (which uses GNU awk), the last line
of the input is printed (and the fields are available via
the positional variables $1 etc.)
There appears to be support (though only implicit) for the
GNU awk interpretation of what should be available under
the END pattern in the SUSv2 specification at
http://www.opengroup.org/onlinepubs/007908799/xcu/awk.html
where it is said that NF and NR retains their values from
the last record seen under the END pattern.
>How-To-Repeat:
See above.
>Fix:
Sorry, none supplied.
However, browsing the code (which I'm not familiar with...)
it seems to me that getrec() should not commit to zeroing the
input buffer as the first thing it does.