[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU awk ver. 3.1.6 OFS-related bug
From: |
Aharon Robbins |
Subject: |
Re: GNU awk ver. 3.1.6 OFS-related bug |
Date: |
Sun, 13 Mar 2011 06:11:32 +0000 (UTC) |
In article <address@hidden>,
George Zarkadas <address@hidden> wrote:
>-=-=-=-=-=-
>
>ΣÏÎ¹Ï 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
I can understand the confusion; I will try to improve the documentation
that changing OFS doesn't affect $0 until one of the fields is changed.
Thanks,
Arnold
--
Aharon (Arnold) Robbins arnold AT skeeve DOT com
P.O. Box 354 Home Phone: +972 8 979-0381
Nof Ayalon Cell Phone: +972 50 729-7545
D.N. Shimshon 99785 ISRAEL