buggrep - Bugs: bug #28329, egrep/fgrep should accept...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #28329: egrep/fgrep should accept respectively -E/-F

Submitter:  None
Submitted:  Fri 18 Dec 2009 04:19:21 AM UTC
   
 
Category:  None Severity:  2 - Minor
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Mon 22 Mar 2010 10:51:01 AM UTC, comment #4: 

I still think setting -E in GREP_OPTIONS is a bad idea.  You said

> I would spend time figuring out a RE at the command prompt only to have it break when I included it in a script


But then you're making everybody else spend time figure out why your scripts break for them.  Include the alias in your scripts too.

Nevertheless, grep 2.6 will support -E in egrep and -F in fgrep.



Thank you for the bug report. This bug has been fixed in the
development sources, which can be downloaded using git from
git://git.sv.gnu.org/grep.git

Paolo Bonzini <bonzini>
Sat 19 Dec 2009 04:00:25 AM UTC, comment #3: 


> I think setting -E in GREP_OPTIONS is an incredibly bad idea
> :-) as it will break scripts.


Since extended REs are almost completely backward compatible with simple REs, I think it is unlikely that this will break many scripts. I haven't found one yet where this is a problem.

> use "alias grep='grep -E'" instead


I tried this for a while. Then I would spend time figuring out a RE at the command prompt only to have it break when I included it in a script. After many frustrating debugging sessions, I set the variable to save my sanity. I'm trying to get into the habit of always using egrep but until that "takes", this is my fallback.

I don't have a problem with programs ignoring incompatible options in cases like this (a warning would be OK) but I'm sure purists do. Years of experience tends to make one a little less dogmatic about things like this. ;-)

Tim H <gnus_notaa919687>
Fri 18 Dec 2009 11:21:49 PM UTC, comment #2: 

Irrelevant to the ticket, but FWIW, I use GREP_OPTIONS to do excludes:
--directories=skip --exclude-dir=.svn --exclude=*~

The only problem I've had is with older greps that don't have the options.  So it goes.

Karl Berry <karl>
Group Member
Fri 18 Dec 2009 11:51:45 AM UTC, comment #1: 

I think setting -E in GREP_OPTIONS is an incredibly bad idea :-) as it will break scripts.  In fact, there are very few options suitable for GREP_OPTIONS: --line-buffered, --binary-files (and synonyms), --devices, --mmap, --binary, and probably nothing else.

If you want to save a letter on every grep invocation, use "alias grep='grep -E'" instead so that scripts do not have automatic -E.  This would fix the issue, since egrep would not see the -E instead.

That said, adding support for -E in egrep and -F in fgrep does have some merit, so I'm changing the summary and leaving the bug open.

Paolo Bonzini <bonzini>
Fri 18 Dec 2009 04:19:21 AM UTC, original submission:  

When the environment variable <b>GREP_OPTIONS=-E</b>, egrep reports an 'unknown option' error.

'grep -E -E' doesn't cause an error and this is theoretically equivalent to egrep with GREP_OPTIONS set.

I believe that egrep should ignore any '-E' option set in GREP_OPTIONS.

'fgrep' has similar issues with <b>GREP_OPTIONS=-F</b>.

Platform: cygwin under Windows XP Pro SP3
egrep -V: GNU grep 2.5.3

To reproduce:
GREP_OPTIONS=-E
egrep --help

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gnus_notaa919687 (Posted a comment)
  • -email is unavailable- added by karl (Posted a comment)
  • -email is unavailable- added by bonzini (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-03-22 bonzini StatusNone Fixed
        Open/ClosedOpen Closed
    2009-12-18 bonzini Severity3 - Normal 2 - Minor
        Summaryegrep error when GREP_OPTIONS=-E egrep/fgrep should accept respectively -E/-F

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code