awk limitation, probably to be documented in the autoconf manual?
"Jens Mad. Schmidt" <[email protected]>
| Newsgroups | gmane.comp.sysutils.autoconf.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hi autoconf maintainers,
the sections "Limitations of Shell Builtins" and "[Limitations of Usual Tools" of the Autoconf manual have the status as a reference for portable shell programming for me.
So how about the following limitation of "awk" related to arrays used in functions:
---- test program ----
function foo( bar )
{
for ( x in bar ) print "foobar";
}
END { foo(); }
---- test program ----
When executing this as "cat /dev/null | <awk> -f <test program>" I get on the test systems I have access to:
------------------------------
AIX host 2 7 00F7BD2A4C00
nawk
awk: must be an array.
The source line number is 3.
------------------------------
HP-UX host B.11.31 U 9000/800 531545342 unlimited-user license
awk
awk: must be an array.
The source line number is 3.
------------------------------
HP-UX host B.11.31 U ia64 3184477447 unlimited-user license
awk
awk: must be an array.
The source line number is 3.
------------------------------
SunOS host 5.10 Generic_Virtual sun4v sparc sun4v
nawk
nawk: (null) is not an array
source line number 3
------------------------------
SunOS host 5.10 Generic_141445-09 i86pc i386 i86pc
nawk
Segmentation Fault - core dumped
------------------------------
Only the GNU "gawk" on GNU/Linux groks that example.
Of course, that use of a local variable as an array may be non-POSIX-ish. Haven't found anything on that.
Thanks for maintaining autoconf!
Jens