bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] /[[.]/ handled incorrectly by gawk and grep.


From: Aharon Robbins
Subject: Re: [bug-gawk] /[[.]/ handled incorrectly by gawk and grep.
Date: Thu, 09 May 2013 13:54:33 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hello.

Thank you for taking the time to send in a bug report.

> Date: Wed, 8 May 2013 12:47:20 -0700 (PDT)
> From: address@hidden
> To: "address@hidden" <address@hidden>
> Subject: [bug-gawk] /[[.]/ handled incorrectly by gawk and grep.
>
> Hey there people,
>
> whilst checking out the latest gawk I found the following bug:
>
> % echo [ | gawk '/[[.]/'
> gawk: cmd. line:1: error: Unmatched [ or [^: /[[.]/
>
> % echo [ | grep '/[[.]/'
> grep: Unmatched [ or [^
>
> % echo [ | gawk311 '/[[.]/'
> [
>
> % echo [ | mawk '/[[.]/'
> [
>
> Grep 2.6.3 delivers the same error.
>
> Gawk versions tested (under Cygwin/Windows 7): 3.1.1 ok;
> 3.1.8, 4.0.0, 4.0.1, 4.0.2, 4.0.75, all not ok.
>
> Regards, W.S.

This change entered gawk with 3.1.2, a mere 10 years ago. That was
the version where I switched to the GLIBC regex matcher from the
original Emacs one.  The message is coming from that part of the code.

I don't consider it a true error, since [.  is used to signal POSIX
collating elements.  Thus, it is rather likely that a pattern such as
/[[.]/ is in error.

For gawk, the proper way to get what you want is to escape the second
open bracket:

        $ echo [ | gawk '/[\[.]/'
        [

This works with other versions of awk as well.

Thanks,

Arnold



reply via email to

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