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: Johann Hartwig Hauschild
Subject: Re: [bug-gawk] Bug regarding setting of OFS
Date: Fri, 10 Feb 2012 15:31:06 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Moin, Aharon.
Du warst folgender Meinung:
> 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. :-)
>
Well, I'm actively using debian-squeeze, so I tried gawk-stable and HEAD to
see if my problem has already been fixed ...

> > ~/.../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).
> 
Hm, ok. I would have thought that setting the OFS to something different
would cause the rebuild as well, but thats probably due to me debugging
awk-scripts running with mawk and gawk.

> This can be confusing.  I believe that there is good coverage of how
> this all works in the gawk manual, please check it out.
> 
Yeah, it says that assigning to an existing field causes a rebuild on
access, I somehow regarded OFS as something fieldish since it influences the
output.


-- 
Thanks,
        Hardy



reply via email to

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