regex-grep can fail if the pattern starts with a hyphen ('-')
Closed this issue · 1 comments
wesley-dean-flexion commented
If the pattern for which one is searching starts with a hyphen (one or more of the '-' character), grep interprets the pattern as another flag, almost always causing the search to fail. For example:
$ grep -rinHE "-dean-flexion" .
/bin/grep: invalid argument ‘ean-flexion’ for ‘--directories’
Valid arguments are:
- ‘read’
- ‘recurse’
- ‘skip’
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
One way to mitigate against this is the usage of the '-e' flag which signals that the next argument represents the pattern for which to search.
https://www.gnu.org/software/grep/manual/grep.html#Matching-Control
(patch / PR forthcoming)
cytopia commented
@wesley-dean-flexion thanks for the detailed explanation. I didn't know about this flag