GNU bug report logs - #31705
five grep / egrep issues

Previous Next

Package: grep;

Reported by: Phillip Feldman <phillip.m.feldman <at> gmail.com>

Date: Mon, 4 Jun 2018 07:24:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31705 in the body.
You can then email your comments to 31705 AT debbugs.gnu.org in the normal way.

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#31705; Package grep. (Mon, 04 Jun 2018 07:24:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Phillip Feldman <phillip.m.feldman <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Mon, 04 Jun 2018 07:24:03 GMT) Full text and rfc822 format available.

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

From: Phillip Feldman <phillip.m.feldman <at> gmail.com>
To: bug-grep <at> gnu.org
Subject: five grep / egrep issues
Date: Sun, 3 Jun 2018 20:48:31 -0700
[Message part 1 (text/plain, inline)]
I would like to report the following unrelated issues:

(1) `grep --help` and `egrep --help` should report the version number.

(2) `egrep [abc]+ *.txt` works as expected, but if I try to do `egrep
^[abc]+ *.txt`, which anchors the pattern to the start of the line, I get
no results,
even though there are lines that match the pattern.

(3) Specifying a pattern for FILE seems to work just fine unless one does a
recursive search.

(4) If one attempts to do a recursive search and omits the starting
directory, it would be helpful if the default were the current working
directory. An
alternative would be to generate a warning or error message. Simply failing
to produce any results is a bad design.

(5) If one provides an invalid regex, e.g., something like '*xyz' (a regex
can't begin with '*'), one should get a fatal error (grep and egrep accept
such a
regex without complaint, and simply return no results).

Phillip M. Feldman
[Message part 2 (text/html, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#31705; Package grep. (Mon, 04 Jun 2018 07:37:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Phillip Feldman <phillip.m.feldman <at> gmail.com>, 31705 <at> debbugs.gnu.org
Subject: Re: bug#31705: five grep / egrep issues
Date: Mon, 4 Jun 2018 00:36:48 -0700
Phillip Feldman wrote:
> I would like to report the following unrelated issues:
> 
> (1) `grep --help` and `egrep --help` should report the version number.

'grep --version' should do what you want. That behavior is specified in the GNU 
coding standards.

> (2) `egrep [abc]+ *.txt` works as expected, but if I try to do `egrep
> ^[abc]+ *.txt`, which anchors the pattern to the start of the line, I get
> no results,
> even though there are lines that match the pattern.

The command works for me. For example:

$ echo 'apple' | egrep ^[abc]+
apple

If it doesn't work for you, please supply a complete self-contained test case.


> (3) Specifying a pattern for FILE seems to work just fine unless one does a
> recursive search.

Sorry, I don't understand the problem here. Can you supply a complete, 
self-contained test case?

> (4) If one attempts to do a recursive search and omits the starting
> directory, it would be helpful if the default were the current working
> directory.

grep does that; at least grep 3.1 does. Perhaps you have an older version; if 
so, please upgrade. For example:

$ mkdir d
$ echo x >d/x
$ cd d
$ grep -r x
x:x

> (5) If one provides an invalid regex, e.g., something like '*xyz' (a regex
> can't begin with '*'), one should get a fatal error (grep and egrep accept
> such a
> regex without complaint, and simply return no results).

The longstanding (i.e., since the late 1970s) tradition here is to treat those 
strings as valid regular expressions, e.g., '*' at the start of a regular 
expression is treated as if it were '\*'. Many users expect this behavior now, 
so we're unlikely to change it. POSIX allows this behavior as an extension.




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Wed, 01 Jan 2020 07:45:02 GMT) Full text and rfc822 format available.

Notification sent to Phillip Feldman <phillip.m.feldman <at> gmail.com>:
bug acknowledged by developer. (Wed, 01 Jan 2020 07:45:02 GMT) Full text and rfc822 format available.

Message #13 received at 31705-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Phillip Feldman <phillip.m.feldman <at> gmail.com>
Cc: 31705-done <at> debbugs.gnu.org
Subject: Re: bug#31705: five grep / egrep issues
Date: Tue, 31 Dec 2019 23:44:26 -0800
No further comment for over a year, so closing the bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 29 Jan 2020 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 82 days ago.

Previous Next


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