bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Assigning to NF


From: Aharon Robbins
Subject: Re: Assigning to NF
Date: Tue, 24 Mar 2009 12:09:20 +0200

Dave,

Harumph.  In 1994(!) I asked for a clarification about increasing NF,
but I guess it got lost. So you're right, what I thought was in POSIX
isn't.  However, you can get what you want in a POSIX fashion by
just doing

        { $(NF+however_much) = ""; ... }

since that does increase NF and cause the record to be rebuilt the
next time $0 is referenced.  Gawk works as I described: incrementing NF
or setting it to a bigger value does the same thing as assigning to
a non-existent field.

HTH,

Arnold

> Date: Mon, 23 Mar 2009 12:15:55 +0100
> From: Dave B <address@hidden>
> To: Aharon Robbins <address@hidden>
> CC: address@hidden
> Subject: Re: Assigning to NF
>
> Aharon Robbins wrote:
>
> > Thanks for the note.  To add more fields, POSIX says just increase NF
> > to the desired value.  The record is then rebuilt automatically the
> > next time it's referenced; the $1 = $1 isn't necessary.
>
> Can you please provide a reference for that? I found nothing in the new
> POSIX specs. The closest thing I've found (but which describes a different
> thing), is this:
>
> "References to nonexistent fields (that is, fields after $NF), shall
> evaluate to the uninitialized value. Such references shall not create new
> fields. However, assigning to a nonexistent field (for example, $(NF+2)=5)
> shall increase the value of NF; create any intervening fields with the
> uninitialized value; and cause the value of $0 to be recomputed, with the
> fields being separated by the value of OFS."
>
> It seems to me that what you said cannot be deduced as a consequence of the
> above text.
>
> Thank you!
>
> -- 
> D.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]