Subject: Re: bin/29659: awk handling of END non-portable
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Havard Eidnes <he@netbsd.org>
List: netbsd-bugs
Date: 03/13/2005 12:23:01
The following reply was made to PR bin/29659; it has been noted by GNATS.

From: Havard Eidnes <he@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: netbsd-bugs@netbsd.org
Subject: Re: bin/29659: awk handling of END non-portable
Date: Sun, 13 Mar 2005 13:22:48 +0100 (CET)

 Hi,
 
 here follows two new regression tests for this particular
 problem, verifying that NF and $0 is retained from the last
 record seen in the input in the END block.
 
 Regards,
 
 - Havard
 
 ------------------------------
 
 # This is a shell archive.  Save it in a file, remove anything before
 # this line, and then unpack it by entering "sh file".  Note, it may
 # create directories; files and directories will be owned by you and
 # have default permissions.
 #
 # This archive contains:
 #
 #	end1/Makefile
 #	end1/expected
 #	end1/input
 #	end1/test.awk
 #	end2/Makefile
 #	end2/expected
 #	end2/input
 #	end2/test.awk
 #
 echo x - end1/Makefile
 sed 's/^X//' >end1/Makefile << 'END-of-end1/Makefile'
 X#	$NetBSD$
 X
 XNOMAN=  	# defined
 X
 X.include <bsd.own.mk>
 X
 XCLEANFILES=	result
 X
 Xregress:
 X	${AWK} -f ${.CURDIR}/test.awk ${.CURDIR}/input > result
 X	@cmp ${.CURDIR}/expected result
 X
 X.include <bsd.prog.mk>
 END-of-end1/Makefile
 echo x - end1/expected
 sed 's/^X//' >end1/expected << 'END-of-end1/expected'
 X4
 END-of-end1/expected
 echo x - end1/input
 sed 's/^X//' >end1/input << 'END-of-end1/input'
 Xa b c d
 END-of-end1/input
 echo x - end1/test.awk
 sed 's/^X//' >end1/test.awk << 'END-of-end1/test.awk'
 X# $Id$
 X
 XEND {
 X	print NF;
 X}
 END-of-end1/test.awk
 echo x - end2/Makefile
 sed 's/^X//' >end2/Makefile << 'END-of-end2/Makefile'
 X#	$NetBSD$
 X
 XNOMAN=  	# defined
 X
 X.include <bsd.own.mk>
 X
 XCLEANFILES=	result
 X
 Xregress:
 X	${AWK} -f ${.CURDIR}/test.awk ${.CURDIR}/input > result
 X	@cmp ${.CURDIR}/expected result
 X
 X.include <bsd.prog.mk>
 END-of-end2/Makefile
 echo x - end2/expected
 sed 's/^X//' >end2/expected << 'END-of-end2/expected'
 Xa b c d
 END-of-end2/expected
 echo x - end2/input
 sed 's/^X//' >end2/input << 'END-of-end2/input'
 Xa b c d
 END-of-end2/input
 echo x - end2/test.awk
 sed 's/^X//' >end2/test.awk << 'END-of-end2/test.awk'
 X# $Id$
 X
 XEND {
 X	print $0;
 X}
 END-of-end2/test.awk
 exit