grep - 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)
Submitter: | None | ||
Submitted: | Mon 22 Nov 2010 11:22:41 PM UTC | ||
Category: | None | Severity: | 3 - Normal |
Item Group: | None | Status: | Invalid |
Privacy: | Public | Assigned to: | None |
Open/Closed: | Closed |
Mon 22 Nov 2010 11:47:23 PM UTC, comment #1: |
Eric Blake <ericb> |
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
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 2 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2010-11-22 | ericb | Status | None | Invalid | |
Open/Closed | Open | Closed |
Powered by Savane 3.13-4b48.
Corresponding source code
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.