Liste des Groupes | Revenir à cl awk |
On 3/13/2024 4:49 PM, Kaz Kylheku wrote:On 2024-03-13, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:>Kaz Kylheku <433-929-6894@kylheku.com> writes:On 2024-03-13, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:arnold@freefriends.org (Aharon Robbins) writes:>In article <usqkgn$he7u$2@dont-email.me>,>
Ed Morton <mortonspam@gmail.com> wrote:the effect of setting `NF` is>
undefined behavior per POSIX and so will do different things in
different awk variants and even in 1 awk variant can behave differently
depending on whether you're setting it to a higher or lower than
original value
This is not true. The effect of setting NF was well defined
by the original awk book and also in POSIX.
>
Decreasing NF throws away fields. Increasing NF adds the
intervening fields with the null string as their values
and rebuilds the record.
I don't see that in the POSIX specification.
The key is this:
>
References to nonexistent fields (that is, fields after $NF), shall
evaluate to the uninitialized value.
>
NF is assignable, and fields after $NF do not exist. Thus if we
have four fields and set NF = 3, then $4 doesn't exist.
That's a bit like the argument from an old episode of the comedy TV show
"Yes, Prime Minister"
in the UK where his aide says (paraphrased) "Some
country has done X, we must go something. War is something, therefore we
must go to war".
>
Being able to set NF to 3 does not mean you must delete $4.
Why not
delete $1 or $2 instead?
You'd still end up with 3 fields to satisfy the
value of NF.
Les messages affichés proviennent d'usenet.