GNU logs - #29613, boring messages


Message sent to bug-grep@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#29613: Debian Bug#883733: grep returns 0 even if there is no match
Resent-From: "Santiago R.R." <santiagorr@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-grep@HIDDEN
Resent-Date: Fri, 08 Dec 2017 11:12:02 +0000
Resent-Message-ID: <handler.29613.B.15127314977629 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 29613
X-GNU-PR-Package: grep
X-GNU-PR-Keywords: 
To: 29613 <at> debbugs.gnu.org
Cc: 883733@HIDDEN
X-Debbugs-Original-To: bug-grep@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.15127314977629
          (code B ref -1); Fri, 08 Dec 2017 11:12:02 +0000
Received: (at submit) by debbugs.gnu.org; 8 Dec 2017 11:11:37 +0000
Received: from localhost ([127.0.0.1]:51420 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eNGZ7-0001yz-9B
	for submit <at> debbugs.gnu.org; Fri, 08 Dec 2017 06:11:37 -0500
Received: from eggs.gnu.org ([208.118.235.92]:60834)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <santiagorr@HIDDEN>) id 1eNGZ5-0001ym-97
 for submit <at> debbugs.gnu.org; Fri, 08 Dec 2017 06:11:35 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <santiagorr@HIDDEN>) id 1eNGYy-0003dQ-Qu
 for submit <at> debbugs.gnu.org; Fri, 08 Dec 2017 06:11:30 -0500
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,T_DKIM_INVALID,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:40929)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <santiagorr@HIDDEN>)
 id 1eNGYy-0003dJ-NK
 for submit <at> debbugs.gnu.org; Fri, 08 Dec 2017 06:11:28 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51793)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <santiagorr@HIDDEN>) id 1eNGYv-0003Yb-Ai
 for bug-grep@HIDDEN; Fri, 08 Dec 2017 06:11:28 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <santiagorr@HIDDEN>) id 1eNGYl-0003Ua-Pz
 for bug-grep@HIDDEN; Fri, 08 Dec 2017 06:11:19 -0500
Received: from mx1.riseup.net ([198.252.153.129]:53893)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <santiagorr@HIDDEN>)
 id 1eNGYl-0003UP-Fc
 for bug-grep@HIDDEN; Fri, 08 Dec 2017 06:11:15 -0500
Received: from piha.riseup.net (unknown [10.0.1.163])
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
 (Client CN "*.riseup.net",
 Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK))
 by mx1.riseup.net (Postfix) with ESMTPS id 3A47E1A1922;
 Fri,  8 Dec 2017 03:11:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak;
 t=1512731470; bh=Mkok3Q4rVBXNRNUh5+s8W3427Yvd5sCcQ2JaHZwps7c=;
 h=Date:From:To:Cc:Subject:From;
 b=m0dl+Y9jZL9k0ylcdyzAsdSmpT5UvC4021pd7i474NkpnVooa61y0uX/wizIk3csl
 NTFlWsRDSR5zcP1saGfAGX6qsJBKFlRTAezGNImRGI7CHb+5nT1b7d+Tmd1gkY3Ypm
 TFe321zOqWHTRMIqDJaM0OoenEePPD9QNM14k9CI=
X-Riseup-User-ID: BD5D30FFC87D9BA34204CE88BA2B9109215150FE6ADDBAF88EC663B4FE14FD6B
Received: from [127.0.0.1] (localhost [127.0.0.1])
 by piha.riseup.net with ESMTPSA id 2EA26228EE0;
 Fri,  8 Dec 2017 03:11:12 -0800 (PST)
Date: Fri, 8 Dec 2017 12:11:10 +0100
From: "Santiago R.R." <santiagorr@HIDDEN>
Message-ID: <20171208111110.d4eigul6fpugqhwo@fedora-23-dvm>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [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: -4.1 (----)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.1 (----)

Dear grep developers,

I would like to forward the report below, filed by Mathias Pietsch to
Debian. I don't want to introduce other noise than this:

$ echo 1111111111111 | grep -E '^1?$' ; echo $?
1
$ echo 1111111111111 | grep -E '^(11+)\1+$' ; echo $?
1
$ echo 1111111111111 | grep -E '^(11+)\1+$|^1?$' ; echo $?
1111111111111
0

Shouldn't the last grep command exit 1 too?

Cheers,

 -- Santiago

----- Forwarded message from Mathias Pietsch <m.pietsch@HIDDEN=
e> -----

Date: Wed, 6 Dec 2017 23:51:52 +0100
From: Mathias Pietsch <m.pietsch@HIDDEN>
To: Debian Bug Tracking System <submit@HIDDEN>
Subject: Bug#883733: grep returns 0 even if there is no match
X-Mailer: reportbug 7.1.7

Package: grep
Version: 2.27-2
Severity: normal
Tags: upstream

when trying to test this famous regexp for matching non-prime numbers
(^1?$|^(11+?)\1+$) which works fine with 'grep -P', i wondered if it
also would work without the non-greedy quantifier so egrep or even
plain grep could use it, and found the following problem e.g., with the
prime number 13:

$ echo "1111111111111" | grep -E '^(11+)\1+$|^1?$' || echo prime
1111111111111

the expected output would have been 'prime' because '1111111111111'
doesn't match '^1?$' and is also no concatanation of two or more
'11', two or more '111', ... opposite to the orignal perl-style
non-greedy version, here the substrings should be tested for a match
beginning with the longest (13 x '1') down to the shortest ('11').

next i removed the empty line term from the regexp (i.e., the '?' from
the '^1?$' term):

$ echo "1111111111111" | grep -E '^(11+)\1+$|^1$' || echo prime
prime

now the result is correct. but since the input in not an empty line,
using '^(11+)\1+$|^1?$' or '^(11+)\1+$|^1$' should not make any
difference.

(making the empty line term a separate term '^(11+)\1+$|^1$|^$' doesn't
change anything. the same is true with using plain grep and
'^\(11\+\)\1\+$\|^1\?$' or '^\(11\+\)\1\+$\|^1$\|^$'.)

this bug also appears in the original upstream version 3.1
(http://ftp.gnu.org/gnu/grep/grep-3.1.tar.xz)


-- System Information:
Debian Release: 9.3
  APT prefers proposed-updates
  APT policy: (500, 'proposed-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=3DC, LC_CTYPE=3Dde_DE.UTF-8 (charmap=3DUTF-8), LANGUAGE=3DC =
(charmap=3DUTF-8)
Shell: /bin/sh linked to /bin/bash
Init: sysvinit (via /sbin/init)

Versions of packages grep depends on:
ii  dpkg          1.18.24
ii  install-info  6.3.0.dfsg.1-1+b2
ii  libc6         2.24-11+deb9u2
ii  libpcre3      2:8.39-3

grep recommends no packages.

Versions of packages grep suggests:
ii  libpcre3  2:8.39-3

-- no debconf information


=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=
=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=
=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=
=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=
=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=
=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=
=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=
=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=
=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=
=E2=94=81=E2=94=81=E2=94=81=E2=94=81

Universit=C3=A4tsklinikum Hamburg-Eppendorf; K=C3=B6rperschaft des =C3=B6=
ffentlichen Rechts;
Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard G=C3=B6ke (Vorsitzender), Prof. D=
r. Dr. Uwe
Koch-Gromus, Joachim Pr=C3=B6l=C3=9F, Martina Saurin (komm.)

=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=
=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=
=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=
=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=
=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=
=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=
=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=
=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=
=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=
=E2=94=81=E2=94=81=E2=94=81=E2=94=81

SAVE PAPER - THINK BEFORE PRINTING



----- End forwarded message -----




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: "Santiago R.R." <santiagorr@HIDDEN>
Subject: bug#29613: Acknowledgement (Debian Bug#883733: grep returns 0
 even if there is no match)
Message-ID: <handler.29613.B.15127314977629.ack <at> debbugs.gnu.org>
References: <20171208111110.d4eigul6fpugqhwo@fedora-23-dvm>
X-Gnu-PR-Message: ack 29613
X-Gnu-PR-Package: grep
Reply-To: 29613 <at> debbugs.gnu.org
Date: Fri, 08 Dec 2017 11:12:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-grep@HIDDEN

If you wish to submit further information on this problem, please
send it to 29613 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
29613: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D29613
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-grep@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#29613: Debian Bug#883733: grep returns 0 even if there is no match
Resent-From: Paul Eggert <eggert@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-grep@HIDDEN
Resent-Date: Fri, 08 Dec 2017 18:36:02 +0000
Resent-Message-ID: <handler.29613.B29613.15127581065558 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 29613
X-GNU-PR-Package: grep
X-GNU-PR-Keywords: 
To: "Santiago R.R." <santiagorr@HIDDEN>, 29613 <at> debbugs.gnu.org
Cc: 883733@HIDDEN
Received: via spool by 29613-submit <at> debbugs.gnu.org id=B29613.15127581065558
          (code B ref 29613); Fri, 08 Dec 2017 18:36:02 +0000
Received: (at 29613) by debbugs.gnu.org; 8 Dec 2017 18:35:06 +0000
Received: from localhost ([127.0.0.1]:52842 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eNNUH-0001RZ-Q5
	for submit <at> debbugs.gnu.org; Fri, 08 Dec 2017 13:35:05 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55580)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1eNNUG-0001R2-51
 for 29613 <at> debbugs.gnu.org; Fri, 08 Dec 2017 13:35:04 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 68B681610B3;
 Fri,  8 Dec 2017 10:34:58 -0800 (PST)
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 u8XQGE-xop0k; Fri,  8 Dec 2017 10:34:57 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7566E1606B2;
 Fri,  8 Dec 2017 10:34:57 -0800 (PST)
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 2qBaM9fCYd3b; Fri,  8 Dec 2017 10:34:57 -0800 (PST)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 5892F160056;
 Fri,  8 Dec 2017 10:34:57 -0800 (PST)
References: <20171208111110.d4eigul6fpugqhwo@fedora-23-dvm>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <e46ed500-3db5-e3fc-23bc-113e15cd5826@HIDDEN>
Date: Fri, 8 Dec 2017 10:34:53 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.4.0
MIME-Version: 1.0
In-Reply-To: <20171208111110.d4eigul6fpugqhwo@fedora-23-dvm>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

On 12/08/2017 03:11 AM, Santiago R.R. wrote:
> $ echo 1111111111111 | grep -E '^(11+)\1+$|^1?$' ; echo $?
> 1111111111111
> 0
>
> Shouldn't the last grep command exit 1 too?

Yes it should. This appears to be due to a longstanding bug in the glibc 
regular expression matcher. See:

https://sourceware.org/bugzilla/show_bug.cgi?id=11053





Message sent to bug-grep@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#29613: Debian Bug#883733: grep returns 0 even if there is no match
Resent-From: Jim Meyering <jim@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-grep@HIDDEN
Resent-Date: Fri, 08 Dec 2017 18:40:02 +0000
Resent-Message-ID: <handler.29613.B29613.15127583565969 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 29613
X-GNU-PR-Package: grep
X-GNU-PR-Keywords: 
To: "Santiago R.R." <santiagorr@HIDDEN>
Cc: 883733@HIDDEN, 29613 <at> debbugs.gnu.org
Received: via spool by 29613-submit <at> debbugs.gnu.org id=B29613.15127583565969
          (code B ref 29613); Fri, 08 Dec 2017 18:40:02 +0000
Received: (at 29613) by debbugs.gnu.org; 8 Dec 2017 18:39:16 +0000
Received: from localhost ([127.0.0.1]:52850 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eNNYJ-0001YD-IK
	for submit <at> debbugs.gnu.org; Fri, 08 Dec 2017 13:39:15 -0500
Received: from mail-qt0-f169.google.com ([209.85.216.169]:35269)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <meyering@HIDDEN>) id 1eNNYF-0001Xx-Mj
 for 29613 <at> debbugs.gnu.org; Fri, 08 Dec 2017 13:39:13 -0500
Received: by mail-qt0-f169.google.com with SMTP id u10so28063831qtg.2
 for <29613 <at> debbugs.gnu.org>; Fri, 08 Dec 2017 10:39:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:sender:in-reply-to:references:from:date:message-id
 :subject:to:cc;
 bh=XSDUk7hMS2NJMMWZ8OdPepI4oUgIb2A5KwqYxpbP4GI=;
 b=IswH5EhorNfwAscyV0sFLHixcGEfhb3FxBkUPuhLMJ0qLgXdprLB6rjuoGJHYihiGw
 cZXThBwzxuqfepUCS0g3k8Fbn0w09Ex2mowmOJhPSgDM5fYAMRR8c/fzWjC6KvQXwv6v
 o8N4rca53DvSQgYRq/asqsd0CyMZBwJeP1+WdiDwokGEHyLTa3Zr6y6xSAqtd0+Ryb/Y
 QgUASebKzvysJywZlXIISTtchM8f+eGZmV9Mqeno2K0JLO9hSZImIbjQ9cfWg2N4Zy2a
 X23sNh0ESzdoRMZjCenelB7qs0J+cnQphZfszfT8hd1r6D1lq0QJzS7x6rY6sWdcZ8tu
 vR1g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
 :date:message-id:subject:to:cc;
 bh=XSDUk7hMS2NJMMWZ8OdPepI4oUgIb2A5KwqYxpbP4GI=;
 b=Qy4ULt1SuvOUdpYokakfxvgyZj/TUPYXjgUOKMIAuQj4WeYcy29VKzusbBGFzdmJ9S
 Zh48v1UPreMg4gE/6rFybOLVKsBKWdkUPuGuKI5Kr1PQeE+cjMLjAISxlbfHbLP1nR5g
 yA4X1Cgumy0Wlb2u69IZlSTPTjpP+h4BSeESNI+Uha9ltszdICZ0ls8mBbfN8JOgPe6T
 Ru1XzMOgNq48tLTPI5jTXxSzjrMOWq7Ap5SwCEED8tqC08e1Dvf3Uqqlh4LfHKJpF5p1
 //8Bx6LqkUjrzYaMJwajh4MtogF3OPImCRSweDXFXdpKG5ipCqguIYMlsuF7DbrWdbUf
 KNkg==
X-Gm-Message-State: AKGB3mLvOFrq2caxiuUFlJv9MDSC0veoCCqbrSWq2gK6nRfHRk6uDOEP
 L8g0KUI4NLYTyCwYiRgxin/2InFv9HSZPG4dTYc=
X-Google-Smtp-Source: ACJfBovmUY11/wxNrTzt8rKvYo+t2T5M7uTQwys6P3CIb0f1PT+MxflBQ5MrxJUSEZFkdxeyVkb8hKeDR+Pz1wxQG4g=
X-Received: by 10.200.39.148 with SMTP id w20mr7095675qtw.178.1512758345912;
 Fri, 08 Dec 2017 10:39:05 -0800 (PST)
MIME-Version: 1.0
Received: by 10.55.9.17 with HTTP; Fri, 8 Dec 2017 10:38:45 -0800 (PST)
In-Reply-To: <20171208111110.d4eigul6fpugqhwo@fedora-23-dvm>
References: <20171208111110.d4eigul6fpugqhwo@fedora-23-dvm>
From: Jim Meyering <jim@HIDDEN>
Date: Fri, 8 Dec 2017 10:38:45 -0800
X-Google-Sender-Auth: sGzXT6eu0HdhqDxm4jeNhyeT72c
Message-ID: <CA+8g5KGt6sy0OiDXfgGkwttG2xVEhrmuTBodeiw88-b=FXpSDg@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.5 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.5 (/)

On Fri, Dec 8, 2017 at 3:11 AM, Santiago R.R. <santiagorr@HIDDEN> wrote:
> Dear grep developers,
>
> I would like to forward the report below, filed by Mathias Pietsch to
> Debian. I don't want to introduce other noise than this:
>
> $ echo 1111111111111 | grep -E '^1?$' ; echo $?
> 1
> $ echo 1111111111111 | grep -E '^(11+)\1+$' ; echo $?
> 1
> $ echo 1111111111111 | grep -E '^(11+)\1+$|^1?$' ; echo $?
> 1111111111111
> 0
>
> Shouldn't the last grep command exit 1 too?
>
> Cheers,
>
>  -- Santiago
>
> ----- Forwarded message from Mathias Pietsch <m.pietsch@HIDDEN> -----
>
> Date: Wed, 6 Dec 2017 23:51:52 +0100
> From: Mathias Pietsch <m.pietsch@HIDDEN>
> To: Debian Bug Tracking System <submit@HIDDEN>
> Subject: Bug#883733: grep returns 0 even if there is no match
> X-Mailer: reportbug 7.1.7
>
> Package: grep
> Version: 2.27-2
> Severity: normal
> Tags: upstream
>
> when trying to test this famous regexp for matching non-prime numbers
> (^1?$|^(11+?)\1+$) which works fine with 'grep -P', i wondered if it
> also would work without the non-greedy quantifier so egrep or even
> plain grep could use it, and found the following problem e.g., with the
> prime number 13:
>
> $ echo "1111111111111" | grep -E '^(11+)\1+$|^1?$' || echo prime
> 1111111111111
>
> the expected output would have been 'prime' because '1111111111111'
> doesn't match '^1?$' and is also no concatanation of two or more
> '11', two or more '111', ... opposite to the orignal perl-style
> non-greedy version, here the substrings should be tested for a match
> beginning with the longest (13 x '1') down to the shortest ('11').
>
> next i removed the empty line term from the regexp (i.e., the '?' from
> the '^1?$' term):
>
> $ echo "1111111111111" | grep -E '^(11+)\1+$|^1$' || echo prime
> prime
>
> now the result is correct. but since the input in not an empty line,
> using '^(11+)\1+$|^1?$' or '^(11+)\1+$|^1$' should not make any
> difference.
>
> (making the empty line term a separate term '^(11+)\1+$|^1$|^$' doesn't
> change anything. the same is true with using plain grep and
> '^\(11\+\)\1\+$\|^1\?$' or '^\(11\+\)\1\+$\|^1$\|^$'.)
>
> this bug also appears in the original upstream version 3.1
> (http://ftp.gnu.org/gnu/grep/grep-3.1.tar.xz)

Yikes! Thanks for forwarding that.
That is indeed a bug. I think it must be due to a bug in glibc's
regexp code, since that's the matcher that grep uses when there is any
back-reference.





Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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