Subject: bug#56077: closed (Re: bug#56077: Pattern Beginning With Dash Throws Error)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 18 Jun 2022 21:51:02 +0000

Your bug report

#56077: Pattern Beginning With Dash Throws Error

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
56077: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56077
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#56077: Pattern Beginning With Dash Throws Error
From: Paul Eggert <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Sat, 18 Jun 2022 16:49:58 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

On 6/18/22 15:05, gazip--- via Bug reports for GNU grep wrote:
> I just encountered a problem where when the search pattern starts with a dash, grep interprets it as an argument parameter.

That's normal for grep. See question 3 of:

https://www.gnu.org/software/grep/manual/html_node/Usage.html

Subject: Pattern Beginning With Dash Throws Error
From: [email-masked]
To: Bug Grep <[email-masked]>
Date: Sat, 18 Jun 2022 22:05:07 +0200 (CEST)
List-Id: <debbugs-submit.debbugs.gnu.org>

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