bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Bug regarding setting of OFS


From: Aharon Robbins
Subject: Re: [bug-gawk] Bug regarding setting of OFS
Date: Fri, 10 Feb 2012 14:50:47 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hello. Re this:

> Date: Thu, 9 Feb 2012 09:32:27 +0100
> From: Johann Hartwig Hauschild <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] Bug regarding setting of OFS
>
> Hi.
>
> I'm experiencing some strange behaviour with the OFS-Builtin:
>
> ~/.../gawk$ ./gawk -V |head -1
> GNU Awk 4.0.70

Hmmm, this would seem to be the tip of the master branch.  In general,
you're better working of the stable branch, since what's on master
could be in who-knows-what kind of shape. :-)

> ~/.../gawk$ echo a:b:c|./gawk -F":" '{OFS=FS; $2="x";print}'
> a:x:c
> ~/.../gawk$ echo a:b:c|./gawk -F":" '{$2="x"; OFS=FS; print}'
> a:x:c
> ~/.../gawk$ echo a:b:c|./gawk -F":" '{$2="x"; print; OFS=FS; print}'
> a x c
> a x c
> ~/.../gawk$ echo a:b:c|./gawk -F":" '{$2="x"; print $1; OFS=FS; print}'
> a
> a:x:c
> ~/.../gawk$ echo a:b:c|./gawk -F":" '{$2="x"; print; $2=$2; OFS=FS; print}'
> a x c
> a:x:c
>
> It seems to me that setting OFS causes the print-Statement to recompile
> $0 only if another $n was touched, that is a bit confusing.

Everything is working correctly.  Indeed, $0 is rebuilt only when
needed (in these cases, when the print statement accesses it).

This can be confusing.  I believe that there is good coverage of how
this all works in the gawk manual, please check it out.

Thanks,

Arnold



reply via email to

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