From unknown Fri Aug 15 15:30:12 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#26322 <26322@debbugs.gnu.org> To: bug#26322 <26322@debbugs.gnu.org> Subject: Status: grep '*' VS grep -E '*' Reply-To: bug#26322 <26322@debbugs.gnu.org> Date: Fri, 15 Aug 2025 22:30:12 +0000 retitle 26322 grep '*' VS grep -E '*' reassign 26322 grep submitter 26322 Julien Denis severity 26322 normal tag 26322 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 31 10:47:22 2017 Received: (at submit) by debbugs.gnu.org; 31 Mar 2017 14:47:22 +0000 Received: from localhost ([127.0.0.1]:54624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctxpi-0006c2-6r for submit@debbugs.gnu.org; Fri, 31 Mar 2017 10:47:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctwkN-0004lf-Ry for submit@debbugs.gnu.org; Fri, 31 Mar 2017 09:37:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctwkI-0000s7-4W for submit@debbugs.gnu.org; Fri, 31 Mar 2017 09:37:42 -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, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59336) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctwkI-0000s0-16 for submit@debbugs.gnu.org; Fri, 31 Mar 2017 09:37:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctwkH-0002my-3G for bug-grep@gnu.org; Fri, 31 Mar 2017 09:37:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctwkG-0000r0-HW for bug-grep@gnu.org; Fri, 31 Mar 2017 09:37:41 -0400 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:35695) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctwkG-0000qe-DF for bug-grep@gnu.org; Fri, 31 Mar 2017 09:37:40 -0400 Received: by mail-qk0-x232.google.com with SMTP id r142so66919065qke.2 for ; Fri, 31 Mar 2017 06:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=RCptAguTtiO03ZhJQIgaTMecgOXLpA1yyJ4KC9Yt+sI=; b=GfqS1IY3zlcda6CtrGHssJdX4sDUC1OwA0APeLidJVP3biJBhPusW2VVdbIMjhllaz LTRnWzC4NRqeakq/K892syUZWAJpTt+3Qliszl/9CUZ12xrduJjOjVJ73IujiE417eLN Dfbr2U5F6C8hWvczSE9xATzcYT1a/47yL1+fHndQfQVGFHZvIrtCcr0vEpJhIefI2+ub MsJK2oVm/t+IrpKKSq/Ybl+wNgNDLiT3PcT4rnXHdZBuwxiB7XXEqv2mKRquY4LzyzhA dZ8Mg09yeSTSfYHRwfAo0ePDxg07/8h71iSMwIpSnYiMOfkAnCJPlYZ+shY0erE+kmqV Bl0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=RCptAguTtiO03ZhJQIgaTMecgOXLpA1yyJ4KC9Yt+sI=; b=tAWqW6FHZdvbIonjxdiz4L5mvxzTT/mNeB3tEgkufpIra5sBGu5jmnQ3stJqaAXGZQ VZhyB4vvf0Y4tAXyazH5Iyac3FI0sisPI6hPjw6Jxb7uDT32vwvuT0ircMVveFUnt6QT /3/Hx8SeilsaWlNQKmJeBAQ4J+qZb3tSZxCJa0E6Zm/lGQAxXwgoFGLUK6uIztLt14i5 WeL6sfZly8+pBGES5jiDOdMRRd5rYLF9Ytmp5XGZWmDQWNwQp1IE3NWyxX4ep8sCojDi QVPqRY6PrZrYxmrFP4d+1ya3skuD84syZp6v1aV1STHQKGW7YYwcGisc3k0yMXVjWdiQ 2K7A== X-Gm-Message-State: AFeK/H0AN719clo1ndH7F7BaoTZ6JV0k8jeWGbV347e3liQo4NUKtnqsmc16v/SFHD66qT+CvyUcjXKVd01R7g== X-Received: by 10.233.232.6 with SMTP id a6mr2630137qkg.53.1490967459054; Fri, 31 Mar 2017 06:37:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.54.198 with HTTP; Fri, 31 Mar 2017 06:37:38 -0700 (PDT) From: Julien Denis Date: Fri, 31 Mar 2017 15:37:38 +0200 Message-ID: Subject: grep '*' VS grep -E '*' To: bug-grep@gnu.org Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 31 Mar 2017 10:47:20 -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: -4.0 (----) Hello, Assuming that "textfile" is a regular non empty text file, is it normal that grep '*' textfile returns nothing but grep -E '*' textfile returns all the lines ? I got this using Debian 7.1 stable and so grep is version 2.20. Would a newer grep version resolve this or is it not a bug (but a valid behavior of the star character in ERE) ? Thanks! Julien From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 31 11:42:51 2017 Received: (at control) by debbugs.gnu.org; 31 Mar 2017 15:42:51 +0000 Received: from localhost ([127.0.0.1]:54686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctyhP-0007zI-5m for submit@debbugs.gnu.org; Fri, 31 Mar 2017 11:42:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30493) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctyhM-0007yz-RY; Fri, 31 Mar 2017 11:42:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B55862EF167; Fri, 31 Mar 2017 15:42:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B55862EF167 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B55862EF167 Received: from [10.10.122.200] (ovpn-122-200.rdu2.redhat.com [10.10.122.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BF3F81872; Fri, 31 Mar 2017 15:42:41 +0000 (UTC) Subject: Re: bug#26322: grep '*' VS grep -E '*' To: Julien Denis , 26322-done@debbugs.gnu.org References: From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <4ccde589-3fec-f76a-7b25-997ce908119c@redhat.com> Date: Fri, 31 Mar 2017 10:42:40 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WWjnqk1sMvfeDKKJg89OxSbUTvG8wc5EB" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 31 Mar 2017 15:42:43 +0000 (UTC) X-Spam-Score: -5.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: -5.0 (-----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WWjnqk1sMvfeDKKJg89OxSbUTvG8wc5EB Content-Type: multipart/mixed; boundary="dH9g4KnFmsx4f3Dsix0JuOfj6taBHhhmR"; protected-headers="v1" From: Eric Blake To: Julien Denis , 26322-done@debbugs.gnu.org Message-ID: <4ccde589-3fec-f76a-7b25-997ce908119c@redhat.com> Subject: Re: bug#26322: grep '*' VS grep -E '*' References: In-Reply-To: --dH9g4KnFmsx4f3Dsix0JuOfj6taBHhhmR Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tag 26322 notabug thanks On 03/31/2017 08:37 AM, Julien Denis wrote: > Hello, >=20 > Assuming that "textfile" is a regular non empty text file, is it > normal that grep '*' textfile returns nothing but grep -E '*' textfile > returns all the lines ? > I got this using Debian 7.1 stable and so grep is version 2.20. > Would a newer grep version resolve this or is it not a bug (but a > valid behavior of the star character in ERE) ? According to POSIX, the regular expression '*' has a different interpretation under BRE than under ERE: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html In BRE (plain 'grep' style), 9.3.3 states that " The shall be special except when used: In a bracket expression As the first character of an entire BRE (after an initial '^', if any)" so it means you are searching for the literal character '*'. In your case of no output, that means that your textfile contains no literal '*' on any line. In ERE ('grep -E' style), 9.4.3 states that "*+?{ 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 an unescaped , , , or " So your regular expression is undefined, and we can make it mean whatever we want (whether we error out, or treat it as equivalent to some other regular expression, it doesn't matter - you are outside the bounds of POSIX so you can't rely on our behavior to be consistent). My guess is that your combination of libc and grep version (yes, it might be different across versions or on different platforms) has an interpretation where '*' is treated the same as searching for zero-or-more instances of the regular expression '', and since the empty regular expression matches everywhere, zero-or-more instances of that regular expression will also match everywhere, and you thus get the result of every line of textfile output. But that doesn't mean you should expect that behavior to stay the same. Maybe you are mixing regular expressions with globs. If you want to search for zero-or-more characters with a glob, you use '*'; but that translates to '.*' in both BRE and ERE syntax. At any rate, I don't see this as a bug, so I'm closing the instance in the bug-tracker, but feel free to reply with further comments or question= s. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --dH9g4KnFmsx4f3Dsix0JuOfj6taBHhhmR-- --WWjnqk1sMvfeDKKJg89OxSbUTvG8wc5EB 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/ iQEcBAEBCAAGBQJY3njwAAoJEKeha0olJ0NqoDMH/2mdhfm89YcAYSuxgtix4J4a pMyRixuYtfyttxi14IMH7UDBYTbBub6uJS99wiA6e4Wa/NiMw2NEHDT4+G3kxrIv JellaSJt+UQ3fqOaA/f/nuiEuDjsh77FgNxbrIkwW3WqjGAAX0IFaf3tfBNS42DP Kdyf62M1Af83RAmu3lPrNsY8GkK9tEFcQj0nbTyjB75nTTmVYC468TmIpZ+EPsXG h1qadiP6lif+K2FzwDVHw92E7cUMbop/555z6a9aSUXDSEqzBaZ4j65oU0/BpsBg FVcc2Dnt4gjYatXW5K9IOWlLj0sWhY84WaE0jpt/RyhXzF2JGfjY7UODz5aFFpQ= =rNk0 -----END PGP SIGNATURE----- --WWjnqk1sMvfeDKKJg89OxSbUTvG8wc5EB-- From unknown Fri Aug 15 15:30:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 29 Apr 2017 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