awk: FS pattern separation issue

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

awk: FS pattern separation issue

Charlene Wendling
>Synopsis: FS pattern separation issue
>Category: awk
>Environment:
        System      : OpenBSD 6.7
        Details     : OpenBSD 6.7-current (GENERIC.MP) #258: Wed Jun 10
20:46:20 MDT 2020
[hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:

        In the latest awk we're proposing, FS pattern separation does
        not work properly and makes neofetch fail to properly get
        the screen resolution:

$ xrandr --nograb --current | awk -F 'connected |\+|\(' '/ connected/
&& $2 {printf $2 ", "}'
ed primary 1920x1080+0+0 (normal left inverted right x axis y axis)
521mm x 293mm,

        Using mawk or gawk, or our previous version of awk returns
        "primary 1920x1080," as expected.

>Fix:

None.

Charlène.


Reply | Threaded
Open this post in threaded view
|

Re: awk: FS pattern separation issue

Stuart Henderson
On 2020/06/11 11:48, Charlene Wendling wrote:

> >Synopsis: FS pattern separation issue
> >Category: awk
> >Environment:
> System      : OpenBSD 6.7
> Details     : OpenBSD 6.7-current (GENERIC.MP) #258: Wed Jun 10
> 20:46:20 MDT 2020
> [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
> Architecture: OpenBSD.amd64
> Machine     : amd64
> >Description:
>
> In the latest awk we're proposing, FS pattern separation does
> not work properly and makes neofetch fail to properly get
> the screen resolution:
>
> $ xrandr --nograb --current | awk -F 'connected |\+|\(' '/ connected/
> && $2 {printf $2 ", "}'
> ed primary 1920x1080+0+0 (normal left inverted right x axis y axis)
> 521mm x 293mm,

It would be better to show the exact text fed into awk, xrandr depends
on the machine you run it on.

For all the old versions I get this with your command:

illegal primary in regular expression connected |+|( at |(

Reply | Threaded
Open this post in threaded view
|

Re: awk: FS pattern separation issue

Charlene Wendling
On Thu, 11 Jun 2020 11:50:48 +0100
Stuart Henderson wrote:

> On 2020/06/11 11:48, Charlene Wendling wrote:
> > >Synopsis: FS pattern separation issue
> > >Category: awk
> > >Environment:
> > System      : OpenBSD 6.7
> > Details     : OpenBSD 6.7-current (GENERIC.MP) #258: Wed
> > Jun 10 20:46:20 MDT 2020
> > [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> >
> > Architecture: OpenBSD.amd64
> > Machine     : amd64
> > >Description:
> >
> > In the latest awk we're proposing, FS pattern separation
> > does not work properly and makes neofetch fail to properly get
> > the screen resolution:
> >
> > $ xrandr --nograb --current | awk -F 'connected |\+|\(' '/
> > connected/ && $2 {printf $2 ", "}'
> > ed primary 1920x1080+0+0 (normal left inverted right x axis y axis)
> > 521mm x 293mm,
>
> It would be better to show the exact text fed into awk, xrandr depends
> on the machine you run it on.
>
> For all the old versions I get this with your command:
>
> illegal primary in regular expression connected |+|( at |(
>
You're right, and i don't know why but some escapes in my command
vanished. I'm attaching a shell test case that will compare with mawk
and gawk if they're available.

awk_testcase (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: awk: FS pattern separation issue

Todd C. Miller-3
In reply to this post by Charlene Wendling
This should be fixed by the commit I just made to awk/lib.c.
The strlcpy() length parameter was incorrect.

 - todd

Reply | Threaded
Open this post in threaded view
|

Re: awk: FS pattern separation issue

Charlene Wendling
On Thu, 11 Jun 2020 06:09:02 -0600
Todd C. Miller wrote:

> This should be fixed by the commit I just made to awk/lib.c.
> The strlcpy() length parameter was incorrect.
>
>  - todd

I can confirm that with the neofetch test case, thanks a lot!