GNU bug report logs - #79639
grep: uwaga: stray \ before +

Previous Next

Package: grep;

Reported by: Michal Ligus <maveilthain <at> gmail.com>

Date: Thu, 16 Oct 2025 13:25:01 UTC

Severity: normal

To reply to this bug, email your comments to 79639 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#79639; Package grep. (Thu, 16 Oct 2025 13:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michal Ligus <maveilthain <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Thu, 16 Oct 2025 13:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michal Ligus <maveilthain <at> gmail.com>
To: bug-grep <at> gnu.org
Subject: grep: uwaga: stray \ before +
Date: Thu, 16 Oct 2025 12:58:59 +0200
[Message part 1 (text/plain, inline)]
How to annoying disable message from output?
the  `| grep -v` not working

Please fix issue (by passing additional argument in example --no-warnings)
to GREP
To reproduce:

cat {your_file} | grep '^\+'
cat {your_file} | grep '^\-'

Thanks, please fix this warning

-- 
mgr inż. Michał Ligus
[Message part 2 (text/html, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#79639; Package grep. (Thu, 16 Oct 2025 15:21:01 GMT) Full text and rfc822 format available.

Message #8 received at 79639 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Michal Ligus <maveilthain <at> gmail.com>, 79639 <at> debbugs.gnu.org
Subject: Re: bug#79639: grep: uwaga: stray \ before +
Date: Thu, 16 Oct 2025 08:20:45 -0700
On 2025-10-16 03:58, Michal Ligus wrote:
> How to annoying disable message from output?

You can use ">&2 /dev/null" for that.

Warning about misuse of "\" helps programmers avoid unportable regular 
expressions, which produce undefined results.




Information forwarded to bug-grep <at> gnu.org:
bug#79639; Package grep. (Thu, 16 Oct 2025 16:05:02 GMT) Full text and rfc822 format available.

Message #11 received at 79639 <at> debbugs.gnu.org (full text, mbox):

From: "Dale R. Worley" <Dale.Worley <at> comcast.net>
To: Michal Ligus <maveilthain <at> gmail.com>
Cc: 79639 <at> debbugs.gnu.org
Subject: Re: bug#79639: grep: uwaga: stray \ before +
Date: Thu, 16 Oct 2025 12:04:36 -0400
Michal Ligus <maveilthain <at> gmail.com> writes:
> To reproduce:
>
> cat {your_file} | grep '^\+'

The message in question is:

    $ grep '^\+' </dev/null
    grep: warning: stray \ before +

The message is correct, in the "basic regular expression" mode, "\+" is
not a legitimate regular expression.

However if you enable "extended regular expression mode", "\+" *is* a
legitimate regular expression, it matches the character "+".  (In this
mode, "+" alone is a regexp operator.)  And grep doesn't give you a
warning:

    $ grep -E '^\+' </dev/null

My recommendation is that you either give grep the -E option, so that
"^\+" correctly denotes what you want to search for, or that you give it
the argument "^+", which correctly denotes what you want to search for
in basic mode.

Dale




This bug report was last modified 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.