GNU bug report logs - #56077
Pattern Beginning With Dash Throws Error

Previous Next

Package: grep;

Reported by: gazip <at> tutanota.com

Date: Sat, 18 Jun 2022 21:44:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: gazip <at> tutanota.com
To: 56077 <at> debbugs.gnu.org
Subject: bug#56077: Pattern Beginning With Dash Throws Error
Date: Sat, 18 Jun 2022 22:05:07 +0200 (CEST)
[Message part 1 (text/plain, inline)]
Hello,

I just encountered a problem where when the search pattern starts with a dash, grep interprets it as an argument parameter. It does not matter in what kind of quotes the pattern is wrapped. See examples below.
$ echo "- break -" | grep "- break -"
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
$ echo "- break -" | grep '- break -'
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
$ echo "- break -" | grep '^- break -'
- break -
$ echo "- break -" | grep "^- break -"
- break -
$ echo "- break -" | grep "-s break -"
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.


grep Version: grep (GNU grep) 3.7


Sincerely,
Gazi
[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 340 days ago.

Previous Next


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