From unknown Fri Aug 15 16:55:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#56077: Pattern Beginning With Dash Throws Error Resent-From: gazip@tutanota.com Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Sat, 18 Jun 2022 21:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56077 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: 56077@debbugs.gnu.org X-Debbugs-Original-To: Bug Grep Received: via spool by submit@debbugs.gnu.org id=B.165558863817924 (code B ref -1); Sat, 18 Jun 2022 21:44:02 +0000 Received: (at submit) by debbugs.gnu.org; 18 Jun 2022 21:43:58 +0000 Received: from localhost ([127.0.0.1]:50305 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2gEY-0004f1-Fo for submit@debbugs.gnu.org; Sat, 18 Jun 2022 17:43:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:49796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2eh0-0002HR-Ge for submit@debbugs.gnu.org; Sat, 18 Jun 2022 16:05:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2eh0-0007YJ-CL for bug-grep@gnu.org; Sat, 18 Jun 2022 16:05:14 -0400 Received: from w4.tutanota.de ([81.3.6.165]:58148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2egy-0000hs-Oy for bug-grep@gnu.org; Sat, 18 Jun 2022 16:05:14 -0400 Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id 038C610602CD for ; Sat, 18 Jun 2022 20:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1655582707; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=DIl1rNgAoTMm7sbdYGknhCwda9rI+wlud1xHKADYkRs=; b=wFBfAqdXfq2d9lQE847cSdH8R1m2V4s7rU1/jl6Z6t6Tf2u1CCn7MWWtTvght7ff 8/16f6SE7JFVymPQrL5MUsgNoEE48vKXRQio4KY/PnR/Hf/LyioZiMYQCYfLrQFJdqI Od7Z0GwsbTj28+7iQNgq/LaK0hfcCe4ea+aFIHGar8OxJjXP98PUM+fCcAR9sOLT/xe kYPI4p3i1SlrpdKf6kQl31jdqNBnkPzCXsqioLO9WPCtvIyctPEBRjnSqWNpxYs9Gph RfTvPdW88MPYe7Aa9zn/rpi+zAI0zk6nLTvlVg9kBOCOCp+fLkavwjbmJWhhEAhAUUI v5xsg8hlHA== Date: Sat, 18 Jun 2022 22:05:07 +0200 (CEST) From: gazip@tutanota.com Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_201829_1065216432.1655582707997" Received-SPF: pass client-ip=81.3.6.165; envelope-from=gazip@tutanota.com; helo=w4.tutanota.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Mailman-Approved-At: Sat, 18 Jun 2022 17:43:57 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) ------=_Part_201829_1065216432.1655582707997 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 ------=_Part_201829_1065216432.1655582707997 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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 -"
<= /span>
grep: invalid option -- ' '
Try = 'grep --help' for more information.
$ echo "- bre= ak -" | grep '- break -'
grep: invalid option -- = ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
<= /div>
$ echo "- break -" | grep '^- break -'
- break -
$ echo "- break -" | grep "^- brea= k -"
- break -
= $ echo "= - break -" | grep "-s break -"
grep: invalid optio= n -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]..= .=
Try 'grep --help' for more information.


grep Version: grep (GNU grep) 3.7
<= div dir=3D"auto">

Si= ncerely,
Gazi
------=_Part_201829_1065216432.1655582707997-- From unknown Fri Aug 15 16:55:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: gazip@tutanota.com Subject: bug#56077: closed (Re: bug#56077: Pattern Beginning With Dash Throws Error) Message-ID: References: <475a372e-2c87-703c-1b7e-99bdc566bc7f@cs.ucla.edu> X-Gnu-PR-Message: they-closed 56077 X-Gnu-PR-Package: grep Reply-To: 56077@debbugs.gnu.org Date: Sat, 18 Jun 2022 21:51:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1655589062-18754-1" This is a multi-part message in MIME format... ------------=_1655589062-18754-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 56077@debbugs.gnu.org. --=20 56077: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D56077 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1655589062-18754-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 56077-done) by debbugs.gnu.org; 18 Jun 2022 21:50:10 +0000 Received: from localhost ([127.0.0.1]:50312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2gKY-0004rL-AT for submit@debbugs.gnu.org; Sat, 18 Jun 2022 17:50:10 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2gKU-0004qh-K7 for 56077-done@debbugs.gnu.org; Sat, 18 Jun 2022 17:50:09 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8F96716010D; Sat, 18 Jun 2022 14:50:00 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id xsRNQW3aSuVx; Sat, 18 Jun 2022 14:49:59 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A94D7160112; Sat, 18 Jun 2022 14:49:59 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vnR_c4js1_0X; Sat, 18 Jun 2022 14:49:59 -0700 (PDT) Received: from [192.168.0.205] (ip72-206-2-24.fv.ks.cox.net [72.206.2.24]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 5448E16010D; Sat, 18 Jun 2022 14:49:59 -0700 (PDT) Message-ID: <475a372e-2c87-703c-1b7e-99bdc566bc7f@cs.ucla.edu> Date: Sat, 18 Jun 2022 16:49:58 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: bug#56077: Pattern Beginning With Dash Throws Error Content-Language: en-US To: gazip@tutanota.com References: From: Paul Eggert In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56077-done Cc: 56077-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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 ------------=_1655589062-18754-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 18 Jun 2022 21:43:58 +0000 Received: from localhost ([127.0.0.1]:50305 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2gEY-0004f1-Fo for submit@debbugs.gnu.org; Sat, 18 Jun 2022 17:43:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:49796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2eh0-0002HR-Ge for submit@debbugs.gnu.org; Sat, 18 Jun 2022 16:05:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2eh0-0007YJ-CL for bug-grep@gnu.org; Sat, 18 Jun 2022 16:05:14 -0400 Received: from w4.tutanota.de ([81.3.6.165]:58148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2egy-0000hs-Oy for bug-grep@gnu.org; Sat, 18 Jun 2022 16:05:14 -0400 Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id 038C610602CD for ; Sat, 18 Jun 2022 20:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1655582707; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=DIl1rNgAoTMm7sbdYGknhCwda9rI+wlud1xHKADYkRs=; b=wFBfAqdXfq2d9lQE847cSdH8R1m2V4s7rU1/jl6Z6t6Tf2u1CCn7MWWtTvght7ff 8/16f6SE7JFVymPQrL5MUsgNoEE48vKXRQio4KY/PnR/Hf/LyioZiMYQCYfLrQFJdqI Od7Z0GwsbTj28+7iQNgq/LaK0hfcCe4ea+aFIHGar8OxJjXP98PUM+fCcAR9sOLT/xe kYPI4p3i1SlrpdKf6kQl31jdqNBnkPzCXsqioLO9WPCtvIyctPEBRjnSqWNpxYs9Gph RfTvPdW88MPYe7Aa9zn/rpi+zAI0zk6nLTvlVg9kBOCOCp+fLkavwjbmJWhhEAhAUUI v5xsg8hlHA== Date: Sat, 18 Jun 2022 22:05:07 +0200 (CEST) From: gazip@tutanota.com To: Bug Grep Message-ID: Subject: Pattern Beginning With Dash Throws Error MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_201829_1065216432.1655582707997" Received-SPF: pass client-ip=81.3.6.165; envelope-from=gazip@tutanota.com; helo=w4.tutanota.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 18 Jun 2022 17:43:57 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) ------=_Part_201829_1065216432.1655582707997 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 ------=_Part_201829_1065216432.1655582707997 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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 -"
<= /span>
grep: invalid option -- ' '
Try = 'grep --help' for more information.
$ echo "- bre= ak -" | grep '- break -'
grep: invalid option -- = ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
<= /div>
$ echo "- break -" | grep '^- break -'
- break -
$ echo "- break -" | grep "^- brea= k -"
- break -
= $ echo "= - break -" | grep "-s break -"
grep: invalid optio= n -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]..= .=
Try 'grep --help' for more information.


grep Version: grep (GNU grep) 3.7
<= div dir=3D"auto">

Si= ncerely,
Gazi
------=_Part_201829_1065216432.1655582707997-- ------------=_1655589062-18754-1--