GNU bug report logs - #15937
inconsistent behavior when using the -f option

Previous Next

Package: grep;

Reported by: Aaron Selk <aaron_selk <at> generalplastics.com>

Date: Wed, 20 Nov 2013 20:18:02 UTC

Severity: normal

Tags: notabug

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 15937 in the body.
You can then email your comments to 15937 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#15937; Package grep. (Wed, 20 Nov 2013 20:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Aaron Selk <aaron_selk <at> generalplastics.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Wed, 20 Nov 2013 20:18:03 GMT) Full text and rfc822 format available.

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

From: Aaron Selk <aaron_selk <at> generalplastics.com>
To: "bug-grep <at> gnu.org" <bug-grep <at> gnu.org>
Subject: inconsistent behavior when using the -f option
Date: Wed, 20 Nov 2013 19:34:51 +0000
[Message part 1 (text/plain, inline)]
The following command produces matches.
# egrep ^[\[].+[\]] /var/log/apache2/error.log

However, if I save the pattern to a file and use the -f option, it produces no matches.
I have to change the pattern to this:
^[\[].+\]

Notice I had to remove the enclosing square brackets to get the literal closing bracket to match when using the -f option.
This is on a Debian Squeeze system. Below is the package information. I am happy to provide more details if you needed.
# apt-cache show grep

Package: grep
Essential: yes
Priority: required
Section: utils
Installed-Size: 1148
Maintainer: Anibal Monsalve Salazar <anibal <at> debian.org>
Architecture: amd64
Version: 2.6.3-3+squeeze1
Provides: rgrep
Depends: dpkg (>= 1.15.4) | install-info
Pre-Depends: libc6 (>= 2.3)
Suggests: libpcre3 (>= 7.7)
Conflicts: rgrep
Filename: pool/main/g/grep/grep_2.6.3-3+squeeze1_amd64.deb
Size: 313920
MD5sum: 7c8b301e28fc614cd99b04ea87ad0fee
SHA1: 7ebde8d23c4efe40d6744ec9f79133c37b7d2150
SHA256: e0bb207f1446f5b560540df30cee048fe623b5de164c5e035323cffb59de1736
Description: GNU grep, egrep and fgrep
'grep' is a utility to search for text in files; it can be used from the
command line or in scripts.  Even if you don't want to use it, other packages
on your system probably will.
.
The GNU family of grep utilities may be the "fastest grep in the west".
GNU grep is based on a fast lazy-state deterministic matcher (about
twice as fast as stock Unix egrep) hybridized with a Boyer-Moore-Gosper
search for a fixed string that eliminates impossible text from being
considered by the full regexp matcher without necessarily having to
look at every character. The result is typically many times faster
than Unix grep or egrep. (Regular expressions containing backreferencing
will run more slowly, however.)
Homepage: http://www.gnu.org/software/grep/
Tag: implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::searchin

Package: grep
Essential: yes
Status: install ok installed
Priority: required
Section: utils
Installed-Size: 768
Maintainer: Anibal Monsalve Salazar <anibal <at> debian.org>
Architecture: amd64
Version: 2.6.3-3
Provides: rgrep
Depends: dpkg (>= 1.15.4) | install-info
Pre-Depends: libc6 (>= 2.3)
Suggests: libpcre3 (>= 7.7)
Conflicts: rgrep
Description: GNU grep, egrep and fgrep
'grep' is a utility to search for text in files; it can be used from the
command line or in scripts.  Even if you don't want to use it, other packages
on your system probably will.
.
The GNU family of grep utilities may be the "fastest grep in the west".
GNU grep is based on a fast lazy-state deterministic matcher (about
twice as fast as stock Unix egrep) hybridized with a Boyer-Moore-Gosper
search for a fixed string that eliminates impossible text from being
considered by the full regexp matcher without necessarily having to
look at every character. The result is typically many times faster
than Unix grep or egrep. (Regular expressions containing backreferencing
will run more slowly, however.)
Homepage: http://www.gnu.org/software/grep/


Aaron Selk
Information Services
4910 Burlington Way
Tacoma, WA 98409
Ph: 253.473.5000
Fax: 253.473.5104
www.generalplastics.com

[emailsig-logo]<http://www.generalplastics.com/>
                              [facebook_resized] <http://www.facebook.com/pages/General-Plastics-Manufacturing-Company/177811009011912>  [twitter_resized] <https://twitter.com/generalplastics>  [linkedin_resized] <http://www.linkedin.com/company/general-plastics-mfg.-co.>  [youtube_resized] <http://www.youtube.com/user/GeneralPlastics>

The contents of this electronic message and any attachments are considered confidential and are intended only for the use of the individual or entity
identified above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this e-mail in error, please notify the sender and delete this message, as well as any attachments.

[Message part 2 (text/html, inline)]
[image001.jpg (image/jpeg, inline)]
[image002.jpg (image/jpeg, inline)]
[image003.jpg (image/jpeg, inline)]
[image004.jpg (image/jpeg, inline)]
[image005.jpg (image/jpeg, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#15937; Package grep. (Thu, 21 Nov 2013 00:55:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: Aaron Selk <aaron_selk <at> generalplastics.com>
Cc: 15937 <at> debbugs.gnu.org
Subject: Re: bug#15937: inconsistent behavior when using the -f option
Date: Wed, 20 Nov 2013 16:53:48 -0800
tags 15937 notabug
close 15937
thanks

On Wed, Nov 20, 2013 at 11:34 AM, Aaron Selk
<aaron_selk <at> generalplastics.com> wrote:
> The following command produces matches.
> # egrep ^[\[].+[\]] /var/log/apache2/error.log
>
> However, if I save the pattern to a file and use the -f option, it produces no matches.
> I have to change the pattern to this:
> ^[\[].+\]
>
> Notice I had to remove the enclosing square brackets to get the literal closing bracket to match when using the -f option.

Thanks for the report, but the only problem is that you have not
quoted the regular expression, and that makes it subject to evaluation
by your shell.

I suggest trying hard to single-quote (double-quote only when
necessary) grep regular expressions that are specified on the command
line.
This demonstrates that a properly-quoted regexp works the same on the
command line as when included as the contents of an -f-specified file:

$ echo '[x]' | grep -E '^[[].+[]]'
[x]
$ echo '[x]' | grep -E -f <(echo '^[[].+[]]')
[x]




Added tag(s) notabug. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Sat, 08 Mar 2014 18:07:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 15937 <at> debbugs.gnu.org and Aaron Selk <aaron_selk <at> generalplastics.com> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Sat, 08 Mar 2014 18:07:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 06 Apr 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 133 days ago.

Previous Next


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