GNU bug report logs -
#54043
Simple regexp bug [contains spoiler for today's wordle]
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54043 in the body.
You can then email your comments to 54043 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#54043
; Package
grep
.
(Thu, 17 Feb 2022 14:51:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Matthew Wilcox <willy <at> infradead.org>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Thu, 17 Feb 2022 14:51:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I noticed this one while doing:
$ grep sha[^s]e five-letter-words
share
which doesn't fit with:
$ grep sha.e five-letter-words
shade
shake
shale
shame
shape
share
shave
A reproducer is easy:
$ echo shame |grep sha[^s]e
(no output)
Almost any change to the regex & input will make it work, even rot-13
of both. For example:
$ echo shamel |grep sha[^s]e
(no output, still fails)
$ echo shamel |grep sha[^s]el
shamel
$ echo sshame |grep ssha[^s]e
sshame
$ echo funzr |grep fun[^f]r
funzr
$ grep --version
grep (GNU grep) 3.7
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others; see
<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
This is Debian amd64, grep package version 3.7-1.
Reply sent
to
Jim Meyering <jim <at> meyering.net>
:
You have taken responsibility.
(Thu, 17 Feb 2022 16:15:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Matthew Wilcox <willy <at> infradead.org>
:
bug acknowledged by developer.
(Thu, 17 Feb 2022 16:15:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 54043-done <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 17, 2022 at 7:46 AM Matthew Wilcox <willy <at> infradead.org> wrote:
> I noticed this one while doing:
>
> $ grep sha[^s]e five-letter-words
> share
>
> which doesn't fit with:
>
> $ grep sha.e five-letter-words
> shade
> shake
> shale
> shame
> shape
> share
> shave
>
> A reproducer is easy:
>
> $ echo shame |grep sha[^s]e
> (no output)
This is not a bug in grep. Your failure to quote the regular expression
means that the argument is first interpreted by the shell.
To demonstrate the argument that "grep" ends up using,
run this from that same directory:
echo sha[^s]e
If I have something named e.g., "shape" in the current directory, that
would print "shape". If I have two matching names, e.g., shave and shale,
it will print both names.
IMHO, it is almost always best to single-quote regular expressions like that.
Quoting your reproducer, you see it works as desired:
$ echo shame |grep 'sha[^s]e'
shame
Information forwarded
to
bug-grep <at> gnu.org
:
bug#54043
; Package
grep
.
(Thu, 17 Feb 2022 17:48:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 54043-close <at> debbugs.gnu.org (full text, mbox):
Never mind. bash glob-expanded 'sha[^s]e' to match 'share' which
was a directory in $HOME. Eventually, I'll learn to quote correctly.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 18 Mar 2022 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 95 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.