NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: standards/44063: awk: setting NF doesn't affect $<fieldnum>



The following reply was made to PR standards/44063; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: standards/44063: awk: setting NF doesn't affect $<fieldnum>
Date: Mon, 8 Nov 2010 19:06:53 +0000

 On Mon, Nov 08, 2010 at 10:10:07AM +0000, Robert Elz wrote:
  >  I think you might be reading more in to that than what it is actually
  >  intended to say - I'd suspect that if changing NF explicitly was meant
  >  to be supported at all, that doc would say something about its effects,
  >  [...]
 
 I don't disagree; on the other hand, awk has traditionally supported
 assigning to builtins, such as $0, and it seems pretty clear from
 analogy and the principle of least surprise what the results of
 assigning to NF should be. Having it do something else arbitrary
 doesn't seem useful, and having it blow up at runtime seems
 undesirable.
 
 So I think this is a good change regardless of whether the standard
 really demands it...
 
 I'd say there there is one open question, which is whether
 
    % echo 1 2 3 | awk '{ NF=2; NF=3; print; }'
 
 should print "1 2" or "1 2 3", IOW, whether assiging NF destroys or
 merely hides subsequent values. That one i could argue either way...
 
 -- 
 David A. Holland
 dholland%netbsd.org@localhost
 


Home | Main Index | Thread Index | Old Index