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

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

Re: GNU awk ver. 3.1.6 OFS-related bug


From: George Zarkadas
Subject: Re: GNU awk ver. 3.1.6 OFS-related bug
Date: Thu, 10 Mar 2011 01:29:33 +0200

Στις 08-03-2011, ημέρα Τρι, και ώρα 23:34 +0000, ο/η Aharon Robbins
έγραψε:
> In article <address@hidden>,
> Andreas Schwab  <address@hidden> wrote:
> >George Zarkadas <address@hidden> writes:
> >
> >> Awk does not honor OFS assignments in the BEGIN block (when FS is also
> >> previously set), unless a statement inside the applied rule's action
> >> forces record reconstitution. 
> >
> >Correct.  $0 is only rebuilt if a field is changed.
> 
> Just to make it 100% clear - the reported behavior is not a bug.
> $0 is the full record, including leading and trailing and intervening
> whitespace.
> 
> Thanks for taking the time to send in a report.
> 
> Arnold

Just a final clarifying note:

The bug is (IMHO of course) in that the behavior in question
is not anticipated here. To explain briefly:

One would expect a simple program like this (I reduce here
the case to the bare minimum), a record/field separator 
transformation, to succeed:

BEGIN {
        RS=""
        FS="\n"
        ORS="\n"
        OFS="\177"
}
{
        print
}

especially when reading the section "4.3 Output Separators"
of the manual and seeing: 

"...In order to change how output fields and records are 
separated, assign new values to the variables OFS and ORS. 
The usual place to do this is in the BEGIN rule (see 
BEGIN/END),..."

as well as a successful example of issuing: "{ print $1, $2 }".

I believe that if it is judged that the implementation is
correct as is and should not change, at least the documentation 
at this point should be amended to highlight this case: that
a $1=$1 is needed when one only needs to change output FS.

(Of course at the time of issuing the report I was unsure of 
the real cause and I just stated the facts as accurately as I 
could).

regards
George Zarkadas

Attachment: signature.asc
Description: Αυτό το σημείο του μηνύματος είναι ψηφιακά υπογεγραμμ ένο


reply via email to

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