[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regexp Provoking an Error Message Contains \y but the Error Message
From: |
arnold |
Subject: |
Re: Regexp Provoking an Error Message Contains \y but the Error Message Displays \b |
Date: |
Fri, 30 Oct 2020 02:10:38 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hi.
This is sort of amusing, at least if you're a geek like me. :-)
You've hit a dark corner in the implementation. When parsing a regexp
and getting ready to compile the regexp, gawk turns \b into a literal
backspace character, and it turns \y into the two characters \b so that
the regexp routines will match a word boundary. (It has worked this
way for decades.)
The error message comes from the regexp routines, which actually
saw '\' and 'b'.
There's not a lot I can do about this...
Thanks,
Arnold
"Neil R. Ormos" <ormos-gnulists17@ormos.org> wrote:
> The regexp in this short example lacks a closing right parenthesis.
>
> > ~/.local/bin/gawk-5.1.0 'BEGIN{ if (a ~ /( \y / ) print "test"}'
> gawk-5.1.0: cmd. line:1: error: Unmatched ( or \(: /( \b /
>
> I have read the manual's explanation of why Gawk requires \y and not \b
> in regexps.
>
> Is it intended that Gawk display "\b" in the error message?
>
> I am using Gawk 5.1.0 built from the advertised release sources dated
> 2020/04/14.
>
> > ~/.local/bin/gawk-5.1.0 --version | head -1
> GNU Awk 5.1.0, API: 3.0 (GNU MPFR 3.1.5, GNU MP 6.1.2)
>
> (Apologies for not testing with the latest from Git. When last I tried
> to build from Git, an unmet dependency interfered.)