[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
traditional awk: lazy splitting of $0?
From: |
Ralf Wildenhues |
Subject: |
traditional awk: lazy splitting of $0? |
Date: |
Sun, 21 Oct 2007 13:00:29 +0200 |
User-agent: |
Mutt/1.5.16 (2007-10-11) |
I have a question about traditional awk (that came up while working on
Paolo's pending autotest patch), regarding this note in autoconf.texi:
Traditional Awk has a limit of 99 fields in a record. You may be
able to circumvent this problem by using `split'.
Can I rely on the fact that splitting of $0 is done lazily? I.e.:
perl -e 'print "x "x100;' | awk '{print $0}'
works with Solaris 2.6 awk, but
perl -e 'print "x "x100;' | awk '{print $1}'
fails with
| awk: record `x x x x x x x x x x ...' has too many fields
| record number 1
but I would like to know whether we can rely on awk to not try the
splitting if $i, i>0, is never referenced. If yes, then I suppose we
can also simplify the config headers and config files awk scripts by not
setting FS at all. OTOH, we might still want to set it as a safeguard
measure against later changes that may happen to inadvertently introduce
splitting again.
Thanks,
Ralf
- traditional awk: lazy splitting of $0?,
Ralf Wildenhues <=