From unknown Sat Aug 16 18:16:24 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#24024 <24024@debbugs.gnu.org> To: bug#24024 <24024@debbugs.gnu.org> Subject: Status: grep: Mixing "max-count" and "after-context" outputs too few lines Reply-To: bug#24024 <24024@debbugs.gnu.org> Date: Sun, 17 Aug 2025 01:16:24 +0000 retitle 24024 grep: Mixing "max-count" and "after-context" outputs too few = lines reassign 24024 grep submitter 24024 Santiago Ruano Rinc=C3=B3n severity 24024 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 19 07:54:10 2016 Received: (at submit) by debbugs.gnu.org; 19 Jul 2016 11:54:10 +0000 Received: from localhost ([127.0.0.1]:56526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPTbG-0003NF-75 for submit@debbugs.gnu.org; Tue, 19 Jul 2016 07:54:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34783) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPTbB-0003MZ-T5 for submit@debbugs.gnu.org; Tue, 19 Jul 2016 07:54:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPTb4-0005A7-88 for submit@debbugs.gnu.org; Tue, 19 Jul 2016 07:53:59 -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,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPTb4-0005A3-4t for submit@debbugs.gnu.org; Tue, 19 Jul 2016 07:53:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPTb1-0002it-P1 for bug-grep@gnu.org; Tue, 19 Jul 2016 07:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPTax-00059R-GU for bug-grep@gnu.org; Tue, 19 Jul 2016 07:53:55 -0400 Received: from mx1.riseup.net ([198.252.153.129]:33260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPTax-00059K-7S for bug-grep@gnu.org; Tue, 19 Jul 2016 07:53:51 -0400 Received: from cotinga.riseup.net (unknown [10.0.1.164]) (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 A965D1A1D20; Tue, 19 Jul 2016 11:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1468929229; bh=/mf5Uj5kUDzCUdCDPFvwVpCaZLIRBGXQY62lC3jX6gc=; h=Date:From:To:Subject:References:In-Reply-To:From; b=TdufgOWWqSMFjLXfKpk/zd/uZmC4WYi7M0F+jAc2h6nV3jFepOz2ZcfAmEvh7dzV2 o5CMPoINqyqrbhSO1jsNXQpZqRlUE5+Fmug4HCpnMQOIKpdICI+lMM1Ea1Px80P2ib YVlDccsbNC0YcZrp9jUtZDwDJbu99orITKuGy27s= Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: santiagorr) with ESMTPSA id AD51140364 Received: by nomada (sSMTP sendmail emulation); Tue, 19 Jul 2016 13:53:45 +0200 Date: Tue, 19 Jul 2016 13:53:45 +0200 From: Santiago Ruano =?iso-8859-1?Q?Rinc=F3n?= To: Igor Bogomazov , 831673@bugs.debian.org, bug-grep Subject: grep: Mixing "max-count" and "after-context" outputs too few lines Message-ID: <20160719115345.GE8786@riseup.net> References: <20160718143025.45b24734@ygrex-t550.ygrex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20160718143025.45b24734@ygrex-t550.ygrex.ru> X-Virus-Scanned: clamav-milter 0.99.2 at mx1.riseup.net X-Virus-Status: Clean Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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-Debbugs-Envelope-To: submit 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.1 (----) Hi, Igor Bogomazov filed the following bug against grep in Debian. El 18/07/16 a las 14:30, Igor Bogomazov escribi=F3: > Package: grep > Version: 2.25-6 > Severity: normal >=20 >=20 > Given after-context=3D3 it is expected to output at least 4 lines > as documented, but adding max-count=3D1 makes it stop on the next > matching line. >=20 > What I do: >=20 > $ printf '%s\n' a b a c | grep -m1 -A3 a >=20 > What I see: >=20 > a > b >=20 > What I expect: >=20 > a > b > a > c >=20 > -- System Information: > Debian Release: stretch/sid > APT prefers unstable > APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') > Architecture: amd64 (x86_64) >=20 > Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores) > Locale: LANG=3Den_US.UTF-8, LC_CTYPE=3Den_US.UTF-8 (charmap=3DUTF-8) > Shell: /bin/sh linked to /bin/dash > Init: systemd (via /run/systemd/system) >=20 > Versions of packages grep depends on: > ii dpkg 1.18.9 > ii install-info 6.1.0.dfsg.1-8 > ii libc6 2.23-1 > ii libpcre3 2:8.38-3.1 >=20 > grep recommends no packages. >=20 > Versions of packages grep suggests: > ii libpcre3 2:8.38-3.1 >=20 > -- no debconf information >=20 Note also the behavior when there is not a second match: % printf '%s\n' a b d c | grep -m1 -A3 a a b d c Cheers, Santiago From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 26 11:38:15 2016 Received: (at 24024) by debbugs.gnu.org; 26 Jul 2016 15:38:15 +0000 Received: from localhost ([127.0.0.1]:38293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bS4Qt-0008UP-Hd for submit@debbugs.gnu.org; Tue, 26 Jul 2016 11:38:15 -0400 Received: from mailgw05.kcn.ne.jp ([61.86.7.212]:48532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bS4Qo-0008Tq-V5 for 24024@debbugs.gnu.org; Tue, 26 Jul 2016 11:38:10 -0400 Received: from mxs01-s (mailgw1.kcn.ne.jp [61.86.15.233]) by mailgw05.kcn.ne.jp (Postfix) with ESMTP id 13ADD880687 for <24024@debbugs.gnu.org>; Wed, 27 Jul 2016 00:37:59 +0900 (JST) X-matriXscan-loop-detect: 573d3a78421e986a8b3f972edc1a4ed9b7e3e4ac Received: from mail05.kcn.ne.jp ([61.86.6.184]) by mxs01-s with ESMTP; Wed, 27 Jul 2016 00:37:56 +0900 (JST) Received: from [10.120.1.66] (i118-21-128-66.s30.a048.ap.plala.or.jp [118.21.128.66]) by mail05.kcn.ne.jp (Postfix) with ESMTPA id 6E0627D0099; Wed, 27 Jul 2016 00:37:56 +0900 (JST) Date: Wed, 27 Jul 2016 00:38:02 +0900 From: Norihiro Tanaka To: Santiago Ruano Rincon Subject: Re: bug#24024: grep: Mixing "max-count" and "after-context" outputs too few lines In-Reply-To: <20160719115345.GE8786@riseup.net> References: <20160718143025.45b24734@ygrex-t550.ygrex.ru> <20160719115345.GE8786@riseup.net> Message-Id: <20160727003801.5F4C.27F6AC2D@kcn.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.65.07 [ja] X-matriXscan-Sophos-AV: Clean X-matriXscan-Action: Approve X-matriXscan: Uncategorized X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 24024 Cc: 24024@debbugs.gnu.org, 831673@bugs.debian.org, ygrex@ygrex.ru 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: -1.3 (-) > Igor Bogomazov filed the following bug against grep in > Debian. > > > $ printf '%s\n' a b a c | grep -m1 -A3 a > > > > What I see: > > > > a > > b > > > > What I expect: > > > > a > > b > > a > > c As long as looking at prepending(), I see that it is designed but not documented. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 08 01:25:13 2016 Received: (at 24024-done) by debbugs.gnu.org; 8 Sep 2016 05:25:13 +0000 Received: from localhost ([127.0.0.1]:53114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhrpo-0004jD-SW for submit@debbugs.gnu.org; Thu, 08 Sep 2016 01:25:13 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:48834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhrpm-0004j1-LM for 24024-done@debbugs.gnu.org; Thu, 08 Sep 2016 01:25:11 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3C19E161123; Wed, 7 Sep 2016 22:25:04 -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 GKyiuMzfd9_V; Wed, 7 Sep 2016 22:25:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 69DFF161169; Wed, 7 Sep 2016 22:25:03 -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 A74RVUFm2V2A; Wed, 7 Sep 2016 22:25:03 -0700 (PDT) Received: from [192.168.1.9] (unknown [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 3E031161123; Wed, 7 Sep 2016 22:25:03 -0700 (PDT) Subject: Re: bug#24024: grep: Mixing "max-count" and "after-context" outputs too few lines To: =?UTF-8?Q?Santiago_Ruano_Rinc=c3=b3n?= References: <20160718143025.45b24734@ygrex-t550.ygrex.ru> <20160719115345.GE8786@riseup.net> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Wed, 7 Sep 2016 22:25:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160719115345.GE8786@riseup.net> Content-Type: multipart/mixed; boundary="------------888D77C071BCDC7A8E09FE99" X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 24024-done Cc: Norihiro Tanaka , 831673@bugs.debian.org, 24024-done@debbugs.gnu.org, ygrex@ygrex.ru 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: -1.1 (-) This is a multi-part message in MIME format. --------------888D77C071BCDC7A8E09FE99 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable >> Given after-context=3D3 it is expected to output at least 4 lines >> as documented, but adding max-count=3D1 makes it stop on the next >> matching line. Thanks for reporting this. Although grep's behavior is documented ("conte= xt does=20 not include matching lines" in the node General Output Control) the=20 documentation could be clearer and I installed the attached patch. --------------888D77C071BCDC7A8E09FE99 Content-Type: text/plain; charset=UTF-8; name="0001-doc-define-context-lines.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-doc-define-context-lines.txt" RnJvbSA5MGEyZGQ4YjdmOTNlZjBhOGYwODc0MWU2ZmNiMDcyMjBmOTU0OWY2IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBXZWQsIDcgU2VwIDIwMTYgMjI6MjI6MzcgLTA3MDAKU3ViamVjdDogW1BBVENI XSBkb2M6IGRlZmluZSAiY29udGV4dCBsaW5lcyIKTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVu dC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PVVURi04CkNvbnRlbnQtVHJhbnNmZXItRW5j b2Rpbmc6IDhiaXQKClJlcG9ydGVkIGJ5IElnb3IgQm9nb21hem92IHZpYSBTYW50aWFnbyBS dWFubyBSaW5jw7NuIChCdWcjMjQwMjQpLgoqIGRvYy9ncmVwLnRleGkgKENvbnRleHQgTGlu ZSBDb250cm9sKTogRGVmaW5lICJjb250ZXh0IGxpbmVzIi4KLS0tCiBkb2MvZ3JlcC50ZXhp IHwgOCArKysrKystLQogMSBmaWxlIGNoYW5nZWQsIDYgaW5zZXJ0aW9ucygrKSwgMiBkZWxl dGlvbnMoLSkKCmRpZmYgLS1naXQgYS9kb2MvZ3JlcC50ZXhpIGIvZG9jL2dyZXAudGV4aQpp bmRleCA4MDc2OGRkLi43ZTUxZDQ1IDEwMDY0NAotLS0gYS9kb2MvZ3JlcC50ZXhpCisrKyBi L2RvYy9ncmVwLnRleGkKQEAgLTMzOCw2ICszMzgsNyBAQCBkbwogZG9uZQogQGVuZCBleGFt cGxlCiAKK0BjaW5kZXggY29udGV4dCBsaW5lcwogV2hlbiBAY29tbWFuZHtncmVwfSBzdG9w cyBhZnRlciBAdmFye251bX0gbWF0Y2hpbmcgbGluZXMsCiBpdCBvdXRwdXRzIGFueSB0c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NpbmRl eCBjb250ZXh0CitAY2luZGV4IGNvbnRleHQgbGluZXMKIFByaW50IEB2YXJ7bnVtfSBsaW5l cyBvZiBsZWFkaW5nIGFuZCB0cmFpbGluZyBvdXRwdXQgY29udGV4dC4KIAogQGl0ZW0gLS1n cm91cC1zZXBhcmF0b3I9QHZhcntzdHJpbmd9Ci0tIAoyLjcuNAoK --------------888D77C071BCDC7A8E09FE99-- From unknown Sat Aug 16 18:16:24 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 06 Oct 2016 11:24:04 +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