buggrep - Bugs: bug #31736, grep chokes on filenames starting...

 
 

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

bug #31736: grep chokes on filenames starting "--" (minus-minus)

Submitted by:  None
Submitted on:  Mon 22 Nov 2010 11:22:41 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: Closed

Mon 22 Nov 2010 11:47:23 PM UTC, comment #1:

Not a bug.

Use 'grep -- --file' or 'grep -- ./--file' instead.

The behavior of -- to end option arguments is mandated by POSIX.

Additionally, when running with POSIXLY_CORRECT set in the environment, you are guaranteed that 'grep str --file' will treat --file as a filename per POSIX (since str is not an option); but when not running with POSIXLY_CORRECT, you are subject to the GNU behavior of option reordering (--file is recognized as an option even though str is not); the same approach of using 'grep -- str --file' also works to avoid this option reordering.

Eric Blake <ericb>
Project Member
Mon 22 Nov 2010 11:22:41 PM UTC, original submission:

When grep strikes a filename starting "--" (minus-minus), it tries to interpret it as a META OPTION and fails-exits for "unknown option". Since such filenames are perfectly legal grep should instead skip and continue (at least.

Anonymous

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ericb (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 22 Nov 2010 11:47:23 PM UTCericbStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1