From unknown Sun Jun 22 07:31:42 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23361 <23361@debbugs.gnu.org> To: bug#23361 <23361@debbugs.gnu.org> Subject: Status: =?UTF-8?Q?=E3=80=90Bug=E3=80=91bug?= report of GNU grep Reply-To: bug#23361 <23361@debbugs.gnu.org> Date: Sun, 22 Jun 2025 14:31:42 +0000 retitle 23361 =E3=80=90Bug=E3=80=91bug report of GNU grep reassign 23361 grep submitter 23361 =E8=B0=A2=E6=95=AC=E9=94=8B severity 23361 normal tag 23361 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 24 13:26:09 2016 Received: (at submit) by debbugs.gnu.org; 24 Apr 2016 17:26:09 +0000 Received: from localhost ([127.0.0.1]:45209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1auNnJ-00025j-KS for submit@debbugs.gnu.org; Sun, 24 Apr 2016 13:26:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1auKzg-0002x6-7p for submit@debbugs.gnu.org; Sun, 24 Apr 2016 10:26:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1auKza-0007Xp-B0 for submit@debbugs.gnu.org; Sun, 24 Apr 2016 10:26:35 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auKza-0007Xl-7w for submit@debbugs.gnu.org; Sun, 24 Apr 2016 10:26:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auKzZ-0004uR-BS for bug-grep@gnu.org; Sun, 24 Apr 2016 10:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1auKzW-0007Wk-5E for bug-grep@gnu.org; Sun, 24 Apr 2016 10:26:33 -0400 Received: from n9-44.mail.139.com ([221.176.9.44]:47917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auKzV-0007Vz-Il for bug-grep@gnu.org; Sun, 24 Apr 2016 10:26:30 -0400 X-RM-SPAM-FLAG: 00000000 Received: from xiejingf@139.com ( [183.54.68.70] ) by ajax-webmail-rmapp-25-11027 (Richmail) with HTTP; Sun, 24 Apr 2016 22:04:45 +0800 (CST) Date: Sun, 24 Apr 2016 22:04:45 +0800 (CST) From: =?utf-8?B?6LCi5pWs6ZSL?= To: bug-grep Message-ID: <2b13571ccf63bd7-0000c.Richmail.00046619276592256813@139.com> Subject: =?UTF-8?B?44CQQnVn44CRYnVnIHJlcG9ydCBvZiBHTlUgZ3JlcA==?= MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_183674_1622614427.1461506685331" X-Priority: 3 X-RM-TRANSID: 2b13571ccf63bd7-0000c X-RM-OA-ENC-TYPE: 0 X-CLIENT-INFO: X-TIMING=0&X-MASSSENT=0&X-SENSITIVE=0 X-Mailer: Richmail_Webapp(V1.8.28)A001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 24 Apr 2016 13:26:04 -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_183674_1622614427.1461506685331 Content-Type: text/plain;charset=UTF-8 Content-Transfer-Encoding: 7bit Hi all, Suppose the file content is as below: abc.h hello world the output of grep "*.h" file and grep -E "*.h file" are different, from my understanding, they should be the same, '*' is a regular expression meta-character. the output should both be abc.h. Please help clarifying this issue! ------=_Part_183674_1622614427.1461506685331 Content-Type: text/html;charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all,
Suppose the file content is as below:
=
abc.h
hello world

the output of grep "*.h" f= ile and grep -E "*.h file" are differ= ent, from my understanding, they should be the same, '*' is a regular expre= ssion meta-character. the output should both be abc= .h.

Please help clarifying this issue!



<= div id=3D"signContainer"> ------=_Part_183674_1622614427.1461506685331-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 25 11:29:11 2016 Received: (at control) by debbugs.gnu.org; 25 Apr 2016 15:29:11 +0000 Received: from localhost ([127.0.0.1]:46672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1auiRj-0003hz-4O for submit@debbugs.gnu.org; Mon, 25 Apr 2016 11:29:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53377) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1auiRg-0003he-EE; Mon, 25 Apr 2016 11:29:08 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B6E99C05681B; Mon, 25 Apr 2016 15:29:02 +0000 (UTC) Received: from [10.3.113.21] (ovpn-113-21.phx2.redhat.com [10.3.113.21]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3PFT1Dw025238; Mon, 25 Apr 2016 11:29:02 -0400 Subject: =?UTF-8?Q?Re:_bug#23361:_=e3=80=90Bug=e3=80=91bug_report_of_GNU_gre?= =?UTF-8?Q?p?= To: =?UTF-8?B?6LCi5pWs6ZSL?= , 23361-done@debbugs.gnu.org References: <2b13571ccf63bd7-0000c.Richmail.00046619276592256813@139.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <571E37BD.1020801@redhat.com> Date: Mon, 25 Apr 2016 09:29:01 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <2b13571ccf63bd7-0000c.Richmail.00046619276592256813@139.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Sgj3VOVLxeuX9IKJ9sTAKVu8I1d7Rl9mk" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: control 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: -6.0 (------) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Sgj3VOVLxeuX9IKJ9sTAKVu8I1d7Rl9mk Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tag 23361 notabug thanks On 04/24/2016 08:04 AM, =E8=B0=A2=E6=95=AC=E9=94=8B wrote: >=20 > Hi all, >=20 > Suppose the file content is as below: >=20 > abc.h >=20 > hello world >=20 >=20 >=20 >=20 > the output of grep "*.h" file and grep -E "*.h file" are different, Correct, and this is not a bug. POSIX defines two different flavors of regular expressions: basic (when you use 'grep' without -E) and extended ('grep -E'): http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html > '*' is a regular expression meta-character. But when it appears as the first character of a regular expression, it had different meanings. Read what POSIX says: For a BRE, in 9.3.3: " * The shall be special except when used: In a bracket expression As the first character of an entire BRE (after an initial '^', if any) " which means that as written, grep "*.h" file is looking for a LITERAL star character followed by the '.' metacharacter for any character followed by a literal 'h'. Your example file did not contain that pattern. For an ERE, in 9.4.3: " *+?{ The , , , and shall be special except when used in a bracket expression (see RE Bracket Expression). Any of the following uses produce undefined results: If these characters appear first in an ERE, or immediately following a , , or " which means you have undefined results according to POSIX, and therefore we can make it mean whatever we want, including ignoring the invalid "*", and searching for the regular expression ".h" instead. Which explains why: grep -E "*.h" file has a match, and adding --color shows that the matching portion is the ".h" portion of the "abc.h" line. >=20 > Please help clarifying this issue! Maybe you are confusing globs (where "*.h" matches "abc.h" because the '.' is a literal character, and the "*" means "one or more characters") with regular expressions (where "." means "any character", and "*" means "zero or more repetitions of the previous regex construct, unless there is no previous regex construct, in which case it is well-defined for BRE but undefined for ERE"). At any rate, this is not a bug in grep, so I'm closing the bug report. But feel free to add further comments or questions on this thread. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Sgj3VOVLxeuX9IKJ9sTAKVu8I1d7Rl9mk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXHje9AAoJEKeha0olJ0NqUQUH/RUlgDO0aEEoirfW189+zJdK GJ/4fM8vv8O9Tuv53Ul3oQ7epfg0yN0uNGiIVSCcssZILl9zINuzQOp99GeVu+OP +0vLC/XoYbXBiof0nDOpEg+f7KrHubgt4a/FD7wWPpkKsQV4HWqYoUzXqVwo9qsw X7cSCSWqA/5tFcyJ7nNcQJx7i3B3OhkBDR4QblNTeaq3cd4s/RH07rjs7pLwwcOp XlbNfRHrWGEiBfKYQZb3a1QTyBf9mGmHu7t9yoaW3RR1V51bVmFnxZIX3haM+MDd MsQOpHZljiYGPuIUhasuq0kUD2H3Ce26IPkX2hq0e3RLehyioFkL4yBniPsfYeg= =Gfcg -----END PGP SIGNATURE----- --Sgj3VOVLxeuX9IKJ9sTAKVu8I1d7Rl9mk-- From unknown Sun Jun 22 07:31:42 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 24 May 2016 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator