[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FPAT/printing fields bug
From: |
arnold |
Subject: |
Re: FPAT/printing fields bug |
Date: |
Fri, 01 Nov 2019 05:57:28 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
"Andrew J. Schorr" <address@hidden> wrote:
> Hi,
>
> On Thu, Oct 31, 2019 at 11:52:22AM -0500, Ed Morton wrote:
> > Looks like there's an FPAT bug in gawk 5.0.1:
> >
> > $ echo ',b' | gawk -v FPAT='[^,]*' '{print $2}'
> > b
> >
> > $ echo ',b' | gawk -v FPAT='[^,]*' '{print $1, $2}'
> >
> > $
> >
> > It can be worked around in the same way as a previous bug
> > (https://lists.gnu.org/archive/html/bug-gawk/2017-04/msg00000.html):
> >
> > $ echo ',b' | gawk -v FPAT='[^,]*' '{oFPAT=FPAT; FPAT="";
> > FPAT=oFPAT; print $1, $2}'
> > b
> > $
>
> Interesting. FYI, a simpler workaround is to access NF. For example:
>
> echo ',b' | ./gawk -v FPAT='[^,]*' '{x = NF; printf "[%s] [%s]\n", $1, $2}'
>
> I don't currently have time to dig deeper...
>
> Regards,
> Andy
>
I reworked the FPAT code in 2017 in response to the bug reported
in the message Ed cited. The current bug was introduced at that
point.
I will work on the code some more. Unfortunately, it's fairly nasty
stuff to get right. Yet another of my overenthusiastic mistakes comes
back to bite me.
Thanks for the report.
Arnold
- Re: FPAT/printing fields bug,
arnold <=