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.

Full log


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]




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

Previous Next


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