bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] more on OFS


From: Aharon Robbins
Subject: Re: [bug-gawk] more on OFS
Date: Sun, 05 Aug 2012 13:00:08 +0300
User-agent: Heirloom mailx 12.4 7/29/08

Hi.  Thanks for this. I have (finally) added something based on
this to the test suite, in the gawk-4.0-stable branch.
I will push it shortly.

Thanks,

Arnold

> Date: Fri, 10 Feb 2012 08:23:17 -0700 (MST)
> From: "Nelson H. F. Beebe" <address@hidden>
> To: address@hidden
> Subject: [bug-gawk]  more on OFS
>
> The reported problem with setting of OFS may be more subtle.  Here is
> a test script run on my system with current versions of three awk
> implementations, and their side-by-side output:
>
>       % cat foo.sh
>       #! /bin/sh -
>
>       awktest()
>       {
>         echo a:b:c | $AWK -F":" '{$2="x"; OFS=FS; print}'
>         echo a:b:c | $AWK -F":" '{$2="x"; print; OFS=FS; print}'
>         echo a:b:c | $AWK -F":" '{$2="x"; print $1; OFS=FS; print}'
>         echo a:b:c | $AWK -F":" '{$2="x"; print; $2=$2; OFS=FS; print}'
>       }
>
>       AWK=gawk ; awktest > foo.gawk
>       AWK=mawk ; awktest > foo.mawk
>       AWK=nawk ; awktest > foo.nawk
>
> Running the script produces three output files that can be viewed like
> this, with my comments in a final column:
>
>       ================================================
>       gawk    mawk    nawk            comments
>       ================================================
>       a:x:c   a x c   a:x:c           1 = 3, 2 differs
>       a x c   a x c   a x c           1 = 2 = 3
>       a x c   a x c   a x c           1 = 2 = 3
>       a       a       a               1 = 2 = 3
>       a:x:c   a x c   a:x:c           1 = 3, 2 differs
>       a x c   a x c   a x c           1 = 2 = 3
>       a:x:c   a x c   a:x:c           1 = 3, 2 differs
>       ================================================
>
> Thus, my latest gawk, and nawk (version 20110810) agree, but mawk
> differs in 3 of the 7 lines.  That suggests a gray area in the
> language that hampers portability, and is perhaps best avoided.
>
> Repeating the tests on about twenty platforms gave identical
> results.
>
> I then ran the test with 69 historical versions of gawk, back to 3.0.0
> from 13-May-1996, and got identical output from all of them.
>
> I personally rarely use OFS, in favor of using printf() to control my
> output, but I agree that OFS can be useful for writing simple filters.
>
> In any event, it would seem desirable to add some extra-vigorous tests
> to the gawk test suite to ensure that the handling of OFS remains
> stable, and in agreement with its documentation.



reply via email to

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