From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 12:24:02 2017 Received: (at submit) by debbugs.gnu.org; 25 Mar 2017 16:24:03 +0000 Received: from localhost ([127.0.0.1]:44504 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1croTy-0006zx-NN for submit@debbugs.gnu.org; Sat, 25 Mar 2017 12:24:02 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59913) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1croTx-0006zQ-J7 for submit@debbugs.gnu.org; Sat, 25 Mar 2017 12:24:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1croTr-0006Oz-IQ for submit@debbugs.gnu.org; Sat, 25 Mar 2017 12:23:56 -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]:42165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1croTr-0006Ov-Ee for submit@debbugs.gnu.org; Sat, 25 Mar 2017 12:23:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1croTq-0001az-Aj for bug-grep@gnu.org; Sat, 25 Mar 2017 12:23:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1croTp-0006Oi-67 for bug-grep@gnu.org; Sat, 25 Mar 2017 12:23:54 -0400 Received: from mail-vk0-x244.google.com ([2607:f8b0:400c:c05::244]:34509) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1croTp-0006Od-03 for bug-grep@gnu.org; Sat, 25 Mar 2017 12:23:53 -0400 Received: by mail-vk0-x244.google.com with SMTP id y16so2660968vky.1 for ; Sat, 25 Mar 2017 09:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to:cc; bh=o/yb1/jGqm35bHA5VBkstfr4PK8lhVD+ldcmEd7yYu8=; b=FXSsCKOPmh4YP0i2cE7EpBIvyxuAZmanW7ftlyciBtLCbo7fy62Yn4B2dnI/MwJkeN Q3fCFQnCCZGOv5RoHOfVl0Ij8pfeOkPA8H12ogFlXm4TXR8Lp8pFir+hS0F90/A4eZoo e+4LFVTiHUQEisb8JWFo6iN+LVNFsNeS/pa0q297s9lSAAOvUVYhI7zHAZVa0c9uqKe/ jdSmnlXMRV9DTqZAWuWMvStm59t1dChYGi8JoZwHU+yTPF/pAs5uaBdXx98xQEabO0LK KcO2Cw5kXit+6G5jzjJgoYCSthVcMsFk2W+/6ffswW1RHUWOcsX7362lPeUdXLZlVJpA cdBw== 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:from:date:message-id:subject :to:cc; bh=o/yb1/jGqm35bHA5VBkstfr4PK8lhVD+ldcmEd7yYu8=; b=fnWIUSmG12/2P6oCDA747wQ/cK6HPU5D4Y1pOYXxYm+Onz4CKnwK2Il/yIlmU2Fn6F YD+P0Fs6XBSA3wuDjuQMK0fkJkz0X3Fr/f+djCBD/yMiOihJiuSF7DvE2svlD4Xjv1SB ZPbO5Tv/HWTsI0Zz2os7ZWYxBukF6vN7Z/HH3XwmVrN0+X0i5/iuiqgt6AiLK/UZO21q sxTbtgcK4YPIYX/bW8xu1q+CIRlGxT5zxHrkx8RKDs61BK15i/yNHy+MZnYNwEIGLbcL v0Zzg/Xohyp6Fu17SkdmxVUvvFNbaavPOdqm2om+lDcRbDjLkvoOq8rPqj7C5/pgi1Gd lCAw== X-Gm-Message-State: AFeK/H0sdpDCDUfhUjdAyCFykfo/biJ2jLr2b22Y+zn0vKYe/UsPHOMCwI4tcaba6Aioznu6Dtoq9wIFwCr1yw== X-Received: by 10.176.5.102 with SMTP id 93mr6759542uax.92.1490459031845; Sat, 25 Mar 2017 09:23:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.59.41 with HTTP; Sat, 25 Mar 2017 09:23:31 -0700 (PDT) From: Jim Meyering Date: Sat, 25 Mar 2017 09:23:31 -0700 X-Google-Sender-Auth: vBoRAi9nET7n0pP6dPampBLE1uE Message-ID: Subject: Re: grep's -m breaks -A To: bug-grep@gnu.org Content-Type: text/plain; charset=UTF-8 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: -3.8 (---) X-Debbugs-Envelope-To: submit Cc: Stepan Kasal , Kevin Brubeck Unhammer , Paul Eggert , Stuart MacDonald , Markus Jochim 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.8 (---) On Sat, Mar 25, 2017 at 12:12 AM, Stuart MacDonald wrote: > Follow-up Comment #3, bug #28588 (project grep): > > I just ran into this, trying to grep for the start of a problem in a 60 Gb > syslog. :-( > > Context must always be printed; the current behaviour is unexpected, > surprising, and counter-intuitive, says the lifetime unified diff user. Please keep the discussion on the mailing list, not on that obsolete tracker. I've added our bug-grep@ address, so this thread will automatically get a new bug number in the debbugs-based tracker. I responded to the OP back in 2010: https://lists.gnu.org/archive/html/bug-grep/2010-02/msg00002.html Repeating part of that here, this behavior is documented, and now tested: `-m NUM' `--max-count=NUM' Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM matching lines are output, `grep' ensures that the standard input is positioned just after the last matching line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. For example, the following shell script makes use of it: while grep -m 1 PATTERN do echo xxxx done < FILE Notice how it says grep takes care to position the standard input that only the specified maximum number of matches are "read". This means *not* printing all of the requested trailing context when that context would contain any additional match. From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 03 13:02:51 2017 Received: (at submit) by debbugs.gnu.org; 3 Jun 2017 17:02:51 +0000 Received: from localhost ([127.0.0.1]:54051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dHCRv-0007jF-5v for submit@debbugs.gnu.org; Sat, 03 Jun 2017 13:02:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dH9aD-0006To-VW for submit@debbugs.gnu.org; Sat, 03 Jun 2017 09:59:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dH9a7-0002bg-7z for submit@debbugs.gnu.org; Sat, 03 Jun 2017 09:59:08 -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,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56430) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dH9a7-0002bM-4e for submit@debbugs.gnu.org; Sat, 03 Jun 2017 09:59:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dH9a5-0001mu-Gq for bug-grep@gnu.org; Sat, 03 Jun 2017 09:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dH9a3-0002Xr-Tj for bug-grep@gnu.org; Sat, 03 Jun 2017 09:59:05 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:36509) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dH9a3-0002UU-K1 for bug-grep@gnu.org; Sat, 03 Jun 2017 09:59:03 -0400 Received: by mail-wm0-x243.google.com with SMTP id k15so23076429wmh.3 for ; Sat, 03 Jun 2017 06:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=rzgCc2h+RUlml0ZPk8PmBp8lOUEMfHb25uXqMvannPk=; b=plqyllowojbwBvr/bc7RtyPGPpXy7sjIoqjOg/X/xXoL5E9qSpCHEonknQK420D6Ve HnRquOCHiEN52umkalhoBrr1ptZDj7vx9BYYjq3f0ZL03YUFU3rHySwjWvRvPRAFuXpc tgLA5isbY8fGx7p/ej/Lf0GgDHyXJ1CuuEIwkVFkeZxJAntyFpMpZRzy4VcXFfROO43O lOs4eGUtmHdJ8HAbgL2sxP6T5j641M+q3gWy56N9YQ19c0dnc9Hj1VKnkh6sSYgwtXHS K8QqDOPpkl4SvaAKMIrdSIpN4ZjPVpWmOFunz8rFuIkJocnX04f8yjmIWZdC2WoMlh3j gBcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=rzgCc2h+RUlml0ZPk8PmBp8lOUEMfHb25uXqMvannPk=; b=UbOx4LtrGTYdSo/hmpY9WUm9DWA1tgpJp84lH6dnnpV9CKTiTNcPljna4nB285hjyB rU2wgOX2G0Kyi3dGT4ODqMmwpiaC3gCrqIGekcFFmp5Eel5KFsIKFnVObyPeYBRxLRfA WnMjRWOPLaAZf0snu1qjJWR3VF6hKG2omV8lLrNyjPX1WxbAIfYaFJv5qhg7ygrDRGWe 62ZMxpZqTsJvhetfLhh3IwBb8mj8/VYM82ixkaFUnGTStcTsp+oiUdShlgaDfGJaazgQ kYnPUaMboHeYw3aRzUpFE1Zk641627e62vIcQpnn9LTNXaWMr4lHR/pJIC+ikBwy2eVF Wq4A== X-Gm-Message-State: AODbwcDMYKnuTVCufCqILGcUE+BL17DlEGVwYTtb1HRPwaTlbtzsPQPo 0vJYUpU5K9SmOrTnXG5mXSsx6mNzkw== X-Received: by 10.28.159.138 with SMTP id i132mr2471139wme.47.1496498340780; Sat, 03 Jun 2017 06:59:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.150.228 with HTTP; Sat, 3 Jun 2017 06:59:00 -0700 (PDT) In-Reply-To: References: From: Stuart MacDonald Date: Sat, 3 Jun 2017 09:59:00 -0400 Message-ID: Subject: Re: grep's -m breaks -A To: Jim Meyering Content-Type: multipart/alternative; boundary="001a1145366a0260b805510eac24" 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: Sat, 03 Jun 2017 13:02:48 -0400 Cc: Stepan Kasal , Paul Eggert , Kevin Brubeck Unhammer , bug-grep@gnu.org, 26254@debbugs.gnu.org, Markus Jochim 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 (----) --001a1145366a0260b805510eac24 Content-Type: text/plain; charset="UTF-8" I saw the documentation. Thinking about this some time later, I've realised this is a no-win. Some users will expect the context no matter what, since that's how context works. Some users will need extra matching lines to absolutely not appear. So making either option the default is wrong for someone. I think it needs to be a parameter. Say -F, --force-context Forces before (-B) after (-A) or both (-C) context to be output when there are matching lines in the context window. Thoughts? ...Stu On Sat, Mar 25, 2017 at 12:23 PM, Jim Meyering wrote: > On Sat, Mar 25, 2017 at 12:12 AM, Stuart MacDonald > wrote: > > Follow-up Comment #3, bug #28588 (project grep): > > > > I just ran into this, trying to grep for the start of a problem in a 60 > Gb > > syslog. :-( > > > > Context must always be printed; the current behaviour is unexpected, > > surprising, and counter-intuitive, says the lifetime unified diff user. > > Please keep the discussion on the mailing list, not on that obsolete > tracker. I've added our bug-grep@ address, so this thread will > automatically get a new bug number in the debbugs-based tracker. > > I responded to the OP back in 2010: > > https://lists.gnu.org/archive/html/bug-grep/2010-02/msg00002.html > > Repeating part of that here, this behavior is documented, and now tested: > > `-m NUM' > `--max-count=NUM' > Stop reading a file after NUM matching lines. If the input is > standard input from a regular file, and NUM matching lines are > output, `grep' ensures that the standard input is positioned just > after the last matching line before exiting, regardless of the > presence of trailing context lines. This enables a calling > process to resume a search. For example, the following shell > script makes use of it: > > while grep -m 1 PATTERN > do > echo xxxx > done < FILE > > Notice how it says grep takes care to position the standard input that > only the specified maximum number of matches are "read". This means > *not* printing all of the requested trailing context when that context > would contain any additional match. > --001a1145366a0260b805510eac24 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I saw the documentation.

Thinking about= this some time later, I've realised this is a no-win. Some users will = expect the context no matter what, since that's how context works. Some= users will need extra matching lines to absolutely not appear. So making e= ither option the default is wrong for someone. I think it needs to be a par= ameter. Say
-F, --force-context
=C2=A0 =C2=A0 Forces be= fore (-B) after (-A) or both (-C) context to be output when there are match= ing lines in the context window.

Thoughts?

...Stu

On Sat, Mar 25, 2017 at 12:23 PM, Jim Meyering <jim@meye= ring.net> wrote:
On Sat, = Mar 25, 2017 at 12:12 AM, Stuart MacDonald
<INVALID.NOREPLY@gnu.org&= gt; wrote:
> Follow-up Comment #3, bug #28588 (project grep):
>
> I just ran into this, trying to grep for the start of a problem in a 6= 0 Gb
> syslog. :-(
>
> Context must always be printed; the current behaviour is unexpected, > surprising, and counter-intuitive, says the lifetime unified diff user= .

Please keep the discussion on the mailing list, not on that obsolete
tracker. I've added our bug-grep@ address, so this thread will
automatically get a new bug number in the debbugs-based tracker.

I responded to the OP back in 2010:

=C2=A0 https://lists.gnu.org/archiv= e/html/bug-grep/2010-02/msg00002.html

Repeating part of that here, this behavior is documented, and now tested:
=C2=A0 =C2=A0 `-m NUM'
=C2=A0 =C2=A0 `--max-count=3DNUM'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Stop reading a file after NUM matching li= nes.=C2=A0 If the input is
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0standard input from a regular file, and N= UM matching lines are
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output, `grep' ensures that the stand= ard input is positioned just
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0after the last matching line before exiti= ng, regardless of the
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0presence of trailing context lines.=C2=A0= This enables a calling
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0process to resume a search.=C2=A0 For exa= mple, the following shell
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0script makes use of it:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 while grep -m 1 PATTERN =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo xxxx
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 done < FILE

Notice how it says grep takes care to position the standard input that
only the specified maximum number of matches are "read". This mea= ns
*not* printing all of the requested trailing context when that context
would contain any additional match.

--001a1145366a0260b805510eac24-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 15 11:33:47 2017 Received: (at submit) by debbugs.gnu.org; 15 Jun 2017 15:33:47 +0000 Received: from localhost ([127.0.0.1]:49774 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLWmI-0000Y8-Uv for submit@debbugs.gnu.org; Thu, 15 Jun 2017 11:33:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41235) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLVTI-0006xZ-Ci for submit@debbugs.gnu.org; Thu, 15 Jun 2017 10:10:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLVTC-0001V8-EX for submit@debbugs.gnu.org; Thu, 15 Jun 2017 10:09: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,HTML_MESSAGE, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dLVTC-0001V3-BD for submit@debbugs.gnu.org; Thu, 15 Jun 2017 10:09:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLVTA-0006iA-VF for bug-grep@gnu.org; Thu, 15 Jun 2017 10:09:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLVT9-0001Ub-TL for bug-grep@gnu.org; Thu, 15 Jun 2017 10:09:56 -0400 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:33198) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLVT9-0001U9-Lw for bug-grep@gnu.org; Thu, 15 Jun 2017 10:09:55 -0400 Received: by mail-pf0-x22e.google.com with SMTP id 83so7993765pfr.0 for ; Thu, 15 Jun 2017 07:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openfinance.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=iydygeQkkhje/o5LZg2QovdQQG9sjiHo1xuwEVCNYSM=; b=G62RS22TKzzNDgLvuTsLvnomAvKWf8oZ9qNvn3+pqT9y8GwRFprHr3rIy9DCs6dh8Y xxEEOGzEVmvy3j4BrgIK7J50+T8kNTzfKUI3P491xVuVAsjHiT4zbmDDETVP9FwSblo/ 1TH6+GH7rayz9Q00C1LSr1i/L4MFpvQAf5Qn4= 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=iydygeQkkhje/o5LZg2QovdQQG9sjiHo1xuwEVCNYSM=; b=XkpvEWUZIkWa1T13KaAvrvU4kS3BRRVLvbf52M7bNglqU/PEaVeYruhTPUamKtyrbC tRqS++shgGZuOvnIy3wOPybFwmFe+W2c9j6sgLIrzWxND7/1aiolhojP/ADDBsxCVwF+ nbYA+jAlKaKOE2plS+Q7hx20hv1rSp8aIN0fThL/0Mx+CdygUarTs1nVja2Y7sH1QMM6 +NrQfp+JyutS62HeFbMqj0ZiQ4GnYe50JBaV2EelwemRyZCD50rqLdsewvGUtF7A7xDv 8u53XmDhs8W+sLdL62HNDHu9lP/+WPuaFzBZLsoPVKgQFT6ifpN2lRiAwbDlYV6r+Imm RPtQ== X-Gm-Message-State: AKS2vOyh4lYkXRsGXlZzJbWtMzjo7WK30sXmQV2bTjO8skMGuocXwke0 +IOLYMMGKnA6wrVZBYb4GJxHKLmrZfgW X-Received: by 10.98.204.150 with SMTP id j22mr5412246pfk.236.1497535793160; Thu, 15 Jun 2017 07:09:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.151.166 with HTTP; Thu, 15 Jun 2017 07:09:52 -0700 (PDT) From: Nicholas Sushkin Date: Thu, 15 Jun 2017 10:09:52 -0400 Message-ID: Subject: bug#26254: grep's -m breaks -A To: stuartm.coding@gmail.com, bug-grep@gnu.org Content-Type: multipart/alternative; boundary="94eb2c144d6afd843005520038ce" 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: Thu, 15 Jun 2017 11:33:46 -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 (----) --94eb2c144d6afd843005520038ce Content-Type: text/plain; charset="UTF-8" I agree with Stu, I wanted to see the first match of an Error in its context, so I used grep -E Error -m 1 -C 10. Grep didn't show the context after the match because there was another match for Error right after the first. I'd like to have an option to see the full context whether it has matches or not. ps. This is actually bug #28588 http://savannah.gnu.org/bugs/?28588 -- *Nicholas Sushkin* --94eb2c144d6afd843005520038ce Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I agree with Stu,

I wanted to see t= he first match of an Error in its context, so I used grep -E Error -m 1 -C = 10.
Grep didn't show the context after the match because there was = another match for Error right after the first.
I'd like to hav= e an option to see the full context whether it has matches or not.

ps. This is actually bug #28588 http://savannah.gnu.org/bugs/?2= 8588
--
Nicholas Sushkin

--94eb2c144d6afd843005520038ce-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 16 00:58:34 2017 Received: (at 26254) by debbugs.gnu.org; 16 Jun 2017 04:58:34 +0000 Received: from localhost ([127.0.0.1]:50079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLjL7-0006IV-V4 for submit@debbugs.gnu.org; Fri, 16 Jun 2017 00:58:34 -0400 Received: from mail-vk0-f48.google.com ([209.85.213.48]:33845) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLjL5-0006II-T2 for 26254@debbugs.gnu.org; Fri, 16 Jun 2017 00:58:32 -0400 Received: by mail-vk0-f48.google.com with SMTP id g66so17022906vki.1 for <26254@debbugs.gnu.org>; Thu, 15 Jun 2017 21:58:31 -0700 (PDT) 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=ZXpYyCitAD/xxuF9gzRYtRD2oBo5l/AYepvpxU7WIX4=; b=JrTXufQbHJp8gKwNlfPaAZry4GTHce0N/YmUvUh259ighz3xKXGNZvwKXjqtxA2ndc LT5hpaf+Ywz/Bgm0XOzrBYLr1+UB5A3220yciUnxFH/JaB4UhUOsuBUUowAnz9OVo0g1 OODoLqokM8L8CVHrm9+xoJjPDJDLNSzZqJ07PrFT3JgZwyHldvYhkHF6Z29yQA52Mhrh KwxF47OwOnQIGUf3Vlfsd1s9DpmtuBv+Vuz57NN5XiFnDEbb3EufLIKwhlsTJnvJqDdE VV6K06pWqLg8liSydF/fT1ch5QZehMXjhMRQOvxV2mcW3FNCtQNEJlcsq/1BQnSZmbcY 6oxw== 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=ZXpYyCitAD/xxuF9gzRYtRD2oBo5l/AYepvpxU7WIX4=; b=tGchoMSLmz6hBbmjAWSYJZAtn/0PE9uLspetY8gO93MOgovhI/fB1qSHUO6PoYqPUq nxHd4BiKAtre77wnWRxy32XNGTBMoHTFvmRMV39v8m9AXyTZXUcTWZxyp2kLlB83Pg6C b+socQYIN93Rfs+n0dSt/kd1A6Bz7TccWXjxpRUi+8vaxh/Bko50v7tIK4Rz8PqP4bx3 3QtLG4TRz/SlutCIvyr5LrzzwiOllYfw43xCeYOJjghfCp9L3lgjJd/di0AkNkcpzTna gm1mJ/n8mpSDdxKE8THaBC0fWGKVzeZNaNZQKtvJ60tW9i/rteEklZ0uwZ3sxjHYj2kQ hoNA== X-Gm-Message-State: AKS2vOw1VJbl/c2VELjqps7njwvwpJQPReodRdINLQjBcYscYnAPtDFW TSeiAB5N6AUBqmnPvhXytD7D3maa3w== X-Received: by 10.31.163.72 with SMTP id m69mr4389656vke.14.1497589106061; Thu, 15 Jun 2017 21:58:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.70.83 with HTTP; Thu, 15 Jun 2017 21:58:05 -0700 (PDT) In-Reply-To: References: From: Jim Meyering Date: Thu, 15 Jun 2017 21:58:05 -0700 X-Google-Sender-Auth: xCwpT2QYzYvIB6I5hDSX-m8Kgvk Message-ID: Subject: Re: bug#26254: grep's -m breaks -A To: Nicholas Sushkin , Paul Eggert Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -1.0 (-) X-Debbugs-Envelope-To: 26254 Cc: 26254@debbugs.gnu.org, Stuart MacDonald 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.0 (-) On Thu, Jun 15, 2017 at 7:09 AM, Nicholas Sushkin wrote: > I agree with Stu, > > I wanted to see the first match of an Error in its context, so I used grep > -E Error -m 1 -C 10. > Grep didn't show the context after the match because there was another > match for Error right after the first. > I'd like to have an option to see the full context whether it has matches > or not. > > ps. This is actually bug #28588 http://savannah.gnu.org/bugs/?28588 I am coming around... I think we may have been too hasty in making this behavior the default. While I see how the current default can be useful, that usage feels like it would be far less common than the usage/expectation that provokes surprising (and likely to provoke malfunction) behavior. What do you think, Paul? Switch the default and add an option for the current-default `--max-count=N`-trumps-`--context=N` behavior? From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 17 23:24:12 2017 Received: (at 26254) by debbugs.gnu.org; 18 Jun 2017 03:24:12 +0000 Received: from localhost ([127.0.0.1]:53878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMQot-0008JL-Ut for submit@debbugs.gnu.org; Sat, 17 Jun 2017 23:24:12 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMQos-0008J9-TH for 26254@debbugs.gnu.org; Sat, 17 Jun 2017 23:24:11 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9D5311600EF; Sat, 17 Jun 2017 20:24: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 svATHaqWKsrF; Sat, 17 Jun 2017 20:24:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id CB6B51600FE; Sat, 17 Jun 2017 20:24: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 nls-K2NzyK98; Sat, 17 Jun 2017 20:24:03 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9BF701600EF; Sat, 17 Jun 2017 20:24:03 -0700 (PDT) Subject: Re: bug#26254: grep's -m breaks -A To: Jim Meyering , Nicholas Sushkin References: From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sat, 17 Jun 2017 20:24:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 26254 Cc: 26254@debbugs.gnu.org, Stuart MacDonald 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: -0.0 (/) Jim Meyering wrote: > What do you think, Paul? Switch the default and add an option for the > current-default `--max-count=3DN`-trumps-`--context=3DN` behavior? I am becoming inclined to change the behavior. That is, grep should consi= der=20 --max-count=3DNUM to mean "only the first NUM matching lines count, as fa= r as=20 matches go". Any remaining lines do not match, by this definition. This = would=20 change the behavior in the way that's being requested. This would also change the meaning of grep -v --max-count=3DNUM, since NU= M would=20 count matches (which is what grep --help says) rather than non-matches. T= his=20 would make grep and grep -v inverses as they probably should be even when= -m is=20 used. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 21 17:10:40 2017 Received: (at 26254) by debbugs.gnu.org; 21 Jun 2017 21:10:40 +0000 Received: from localhost ([127.0.0.1]:60316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNmtc-0004fD-4V for submit@debbugs.gnu.org; Wed, 21 Jun 2017 17:10:40 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:52792) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNmta-0004f1-2V for 26254@debbugs.gnu.org; Wed, 21 Jun 2017 17:10:39 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 260891600D3; Wed, 21 Jun 2017 14:10:32 -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 3zhE3Ikc63n9; Wed, 21 Jun 2017 14:10:30 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 63A1D1600D5; Wed, 21 Jun 2017 14:10:30 -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 LXMNUVSG3R3m; Wed, 21 Jun 2017 14:10:30 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C27C61600D6; Wed, 21 Jun 2017 14:10:29 -0700 (PDT) Subject: Re: bug#26254: grep's -m breaks -A From: Paul Eggert To: Jim Meyering , Nicholas Sushkin References: Organization: UCLA Computer Science Department Message-ID: <2cb7f5a6-cfe9-b05e-2c29-7aee00e6c70f@cs.ucla.edu> Date: Wed, 21 Jun 2017 14:10:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------C476380D0B49FCD44E27B9A7" Content-Language: en-US X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 26254 Cc: 26254@debbugs.gnu.org, Stuart MacDonald 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: -0.0 (/) This is a multi-part message in MIME format. --------------C476380D0B49FCD44E27B9A7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 06/17/2017 08:24 PM, Paul Eggert wrote: > > This would also change the meaning of grep -v --max-count=NUM After looking into this, my proposal was too drastic. So I am attaching a more modest patch that would simply change grep's behavior along the lines requested. Athough this is an incompatible change, I think almost all users who care about it will prefer the new behavior. If there is a problem with it I suppose we could have an option to select the old behavior, but I hope it doesn't come to that. --------------C476380D0B49FCD44E27B9A7 Content-Type: text/x-patch; name="0001-grep-m-no-longer-cuts-off-trailing-context.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-grep-m-no-longer-cuts-off-trailing-context.patch" >From 2ee0422feeec5a324efca117264320e562e255ac Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 21 Jun 2017 13:59:57 -0700 Subject: [PATCH] grep: -m no longer cuts off trailing context * NEWS, doc/grep.texi (General Output Control): Document this. * src/grep.c (prpending): Selected lines no longer cut off context. (usage): Say "selected" instead of "matching", where appropriate. * tests/foad1, tests/max-count-vs-context, tests/yesno: Adjust to match new behavior. --- NEWS | 5 +++++ doc/grep.texi | 10 ++++------ src/grep.c | 29 ++++++++++------------------- tests/foad1 | 8 ++++---- tests/max-count-vs-context | 2 +- tests/yesno | 8 ++++---- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/NEWS b/NEWS index 0a8cbbc..bd2c00a 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,11 @@ GNU grep NEWS -*- outline -*- ** Changes in behavior + Context no longer excludes selected lines omitted because of -m. + For example, 'grep "^" -m1 -A1' now outputs the first two input + lines, not just the first line. This fixes a glitch that has been + present since -m was added in grep 2.5. + The following changes affect only MS-Windows platforms. First, the --binary (-U) option now governs whether binary I/O is used, instead of a heuristic that was sometimes incorrect. Second, the diff --git a/doc/grep.texi b/doc/grep.texi index 728c039..334a059 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -311,11 +311,11 @@ The scanning of each file stops on the first match. @opindex -m @opindex --max-count @cindex max-count -Stop reading a file after @var{num} matching lines. +Stop after the first @var{num} selected lines. If the input is standard input from a regular file, -and @var{num} matching lines are output, +and @var{num} selected lines are output, @command{grep} ensures that the standard input is positioned -just after the last matching line before exiting, +just after the last selected line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. For example, the following shell script makes use of it: @@ -340,10 +340,8 @@ done @end example @cindex context lines -When @command{grep} stops after @var{num} matching lines, +When @command{grep} stops after @var{num} selected lines, it outputs any trailing context lines. -Since context does not include matching lines, -@command{grep} will stop when it encounters another matching line. When the @option{-c} or @option{--count} option is also used, @command{grep} does not output a count greater than @var{num}. When the @option{-v} or @option{--invert-match} option is also used, diff --git a/src/grep.c b/src/grep.c index bc2599f..8d22aec 100644 --- a/src/grep.c +++ b/src/grep.c @@ -1011,7 +1011,7 @@ static intmax_t out_before; /* Lines of leading context. */ static intmax_t out_after; /* Lines of trailing context. */ static bool count_matches; /* Count matching lines. */ static bool no_filenames; /* Suppress file names. */ -static intmax_t max_count; /* Stop after outputting this many +static intmax_t max_count; /* Max number of selected lines from an input file. */ static bool line_buffered; /* Use line buffering. */ static char *label = NULL; /* Fake filename for stdin */ @@ -1023,7 +1023,7 @@ static char const *lastnl; /* Pointer after last newline counted. */ static char *lastout; /* Pointer after last character output; NULL if no character has been output or if it's conceptually before bufbeg. */ -static intmax_t outleft; /* Maximum number of lines to be output. */ +static intmax_t outleft; /* Maximum number of selected lines. */ static intmax_t pending; /* Pending lines of output. Always kept 0 if out_quiet is true. */ static bool done_on_match; /* Stop scanning file on first match. */ @@ -1276,25 +1276,16 @@ prline (char *beg, char *lim, char sep) lastout = lim; } -/* Print pending lines of trailing context prior to LIM. Trailing context ends - at the next matching line when OUTLEFT is 0. */ +/* Print pending lines of trailing context prior to LIM. */ static void prpending (char const *lim) { if (!lastout) lastout = bufbeg; - while (pending > 0 && lastout < lim) + for (; 0 < pending && lastout < lim; pending--) { char *nl = memchr (lastout, eolbyte, lim - lastout); - size_t match_size; - --pending; - if (outleft - || ((execute (compiled_pattern, lastout, nl + 1 - lastout, - &match_size, NULL) == (size_t) -1) - == !out_invert)) - prline (lastout, nl + 1, SEP_CHAR_REJECTED); - else - pending = 0; + prline (lastout, nl + 1, SEP_CHAR_REJECTED); } } @@ -1949,11 +1940,11 @@ Miscellaneous:\n\ printf (_("\ \n\ Output control:\n\ - -m, --max-count=NUM stop after NUM matches\n\ + -m, --max-count=NUM stop after NUM selected lines\n\ -b, --byte-offset print the byte offset with output lines\n\ -n, --line-number print line number with output lines\n\ --line-buffered flush output on every line\n\ - -H, --with-filename print the file name for each match\n\ + -H, --with-filename print file name with output lines\n\ -h, --no-filename suppress the file name prefix on output\n\ --label=LABEL use LABEL as the standard input file name prefix\n\ ")); @@ -1981,9 +1972,9 @@ Output control:\n\ --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\ ")); printf (_("\ - -L, --files-without-match print only names of FILEs containing no match\n\ - -l, --files-with-matches print only names of FILEs containing matches\n\ - -c, --count print only a count of matching lines per FILE\n\ + -L, --files-without-match print only names of FILEs with no selected lines\n\ + -l, --files-with-matches print only names of FILEs with selected lines\n\ + -c, --count print only a count of selected lines per FILE\n\ -T, --initial-tab make tabs line up (if needed)\n\ -Z, --null print 0 byte after FILE name\n")); printf (_("\ diff --git a/tests/foad1 b/tests/foad1 index 0163f1a..e399981 100755 --- a/tests/foad1 +++ b/tests/foad1 @@ -93,12 +93,12 @@ grep_test "wordword/" "${CB}word${CE}word/" "\ exp || framework_failure_ +sed 6q in > exp || framework_failure_ fail=0 grep -m1 -A5 needle in > out 2>err || fail=1 diff --git a/tests/yesno b/tests/yesno index e379c19..1ae2142 100755 --- a/tests/yesno +++ b/tests/yesno @@ -73,14 +73,14 @@ set x \ '-C,1,--no-gr' "$rB$C$D$E$rF$rG$H$I$rJ$rL$M$N$z0" \ '-m,4' "$C$D$E$H$z0$XI$XJ$XK$XL$XM$XN" \ '-m,4,-o' "$c$d$e$h$z0$XI$XJ$XK$XL$XM$XN" \ - '-m,4,-C,1' "$rB$C$D$E$rF$rG$H$z0$XI$XJ$XK$XL$XM$XN" \ + '-m,4,-C,1' "$rB$C$D$E$rF$rG$H$rI$z0$XI$XJ$XK$XL$XM$XN" \ '-m,4,-C,1,-o' "$c$d$e$h$z0$XI$XJ$XK$XL$XM$XN" \ '-m,5' "$C$D$E$H$I$z0$XJ$XK$XL$XM$XN" \ '-m,5,-o' "$c$d$e$h$i$z0$XJ$XK$XL$XM$XN" \ '-m,5,-C,1,-o' "$c$d$e$h$i$z0$XJ$XK$XL$XM$XN" \ '-m,6' "$C$D$E$H$I$M$z0$XN" \ '-m,6,-o' "$c$d$e$h$i$m$z0$XN" \ - '-m,6,-C,1' "$rB$C$D$E$rF$rG$H$I$rJ$s$rL$M$z0$XN" \ + '-m,6,-C,1' "$rB$C$D$E$rF$rG$H$I$rJ$s$rL$M$rN$z0$XN" \ '-m,6,-C,1,-o' "$c$d$e$h$i$s$m$z0$XN" \ '-v' "$A$B$F$G$J$K$L$z0" \ '-v,-o' "$z0" \ @@ -92,13 +92,13 @@ set x \ '-4,-v,-1' "$A$B$rC$s$rE$F$G$rH$rI$J$K$L$rM$z0" \ '-m,1,-v' "$A$z0$XB$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \ '-m,1,-v,-o' "$z0$XB$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \ - '-m,1,-v,-C,1' "$A$z0$XB$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \ + '-m,1,-v,-C,1' "$A$rB$z0$XB$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \ '-m,1,-v,-C,1,-o' "$z0$XB$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \ '-m,2,-v' "$A$B$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \ '-m,2,-v,-o' "$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \ '-m,3,-v' "$A$B$F$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \ '-m,3,-v,-o' "$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \ - '-m,3,-v,-C,1' "$A$B$rC$s$rE$F$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \ + '-m,3,-v,-C,1' "$A$B$rC$s$rE$F$rG$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \ '-m,3,-v,-C,1,-o' "$rc$s$re$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \ x shift -- 2.9.4 --------------C476380D0B49FCD44E27B9A7-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 21 21:27:31 2017 Received: (at 26254) by debbugs.gnu.org; 22 Jun 2017 01:27:31 +0000 Received: from localhost ([127.0.0.1]:60427 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNquB-0005kj-4W for submit@debbugs.gnu.org; Wed, 21 Jun 2017 21:27:31 -0400 Received: from mail-ua0-f193.google.com ([209.85.217.193]:33360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNqu9-0005kX-Db for 26254@debbugs.gnu.org; Wed, 21 Jun 2017 21:27:29 -0400 Received: by mail-ua0-f193.google.com with SMTP id z34so337041uab.0 for <26254@debbugs.gnu.org>; Wed, 21 Jun 2017 18:27:29 -0700 (PDT) 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=4dMyrbUp/jE3Ncfn9h2x26cCOPSiLC5cc+BMbh4EtUo=; b=KWXVQAz6OqvbwKprorkOWIO8JEZs6YMN8rzyowdP41/2XG7CaYvtUAOEufmgPoWTpk I8IJVf6DBcRc6xscUMQ9ru8FmuXMTvbWuDqPENFaFyynQgjpJ1gk2VJ9oE0XFm7+uqUG FmrGHfxOg/PTCo9EacRdo3aFrH6AfQanG20YYTlH/ZrEvMVxn/Oas3MeM7HgksUyebzO smnZpnl71ZEjSO2ZydH4yyyaFcuKR6Ax7d/hLPFd/QerYJYarAGe90uuO81Ye/teaNml pvnhbYUxvNbkGKw+UCvRjnbHxCvdCxMQbsafwbNmN+WO5+FTosg298WjKgOToq8qQMRG UjIg== 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=4dMyrbUp/jE3Ncfn9h2x26cCOPSiLC5cc+BMbh4EtUo=; b=qwUHgsbKPxITrTCNX36zHq5KqUaRxjHjnqTVSAZJabSEOHnqQ9VKM8Vx9WLfD/iT10 SARY/AEa9EjLziZraWfMJnZOOIIlpdNnOkq1BLC8HN15rvyEJ5vvVAsGQV/d1TUI4Lmh Be1h8hLRIUvGYMsYjo0Nmo4kY43GxpZX1LaohK7c+kwVo4M/3XLmMCTLIXySFRCMWLlK VAPzMCilGbeeSxxcF/JdG2wZ6e/j8y2lU0KNNuTtdGRj1ElGCEWOf3eNBc1me7g5y9cg x0hr9RS9OZ6D/Xl9ZTnZt7y9HF4bCfmjP/TAOkhhTxQWybuuYT+dsatcAcF+KRYVtTEZ CIxQ== X-Gm-Message-State: AKS2vOzalBaFvnq4BYpAKa/SOY1qk/eut3JWoK6bjMhpeJ+A57KzU4AN jvvp6zwX/3+IGqlp94GKlPwwk1kByw== X-Received: by 10.176.1.212 with SMTP id 78mr88227ual.32.1498094843732; Wed, 21 Jun 2017 18:27:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.70.83 with HTTP; Wed, 21 Jun 2017 18:27:02 -0700 (PDT) In-Reply-To: <2cb7f5a6-cfe9-b05e-2c29-7aee00e6c70f@cs.ucla.edu> References: <2cb7f5a6-cfe9-b05e-2c29-7aee00e6c70f@cs.ucla.edu> From: Jim Meyering Date: Wed, 21 Jun 2017 18:27:02 -0700 X-Google-Sender-Auth: QNvHQvFZdO4ABNQ7DrObPJwYbhQ Message-ID: Subject: Re: bug#26254: grep's -m breaks -A To: Paul Eggert Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 26254 Cc: 26254@debbugs.gnu.org, Nicholas Sushkin , Stuart MacDonald 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: -0.0 (/) On Wed, Jun 21, 2017 at 2:10 PM, Paul Eggert wrote: > On 06/17/2017 08:24 PM, Paul Eggert wrote: >> >> >> This would also change the meaning of grep -v --max-count=NUM > > > After looking into this, my proposal was too drastic. So I am attaching a > more modest patch that would simply change grep's behavior along the lines > requested. Athough this is an incompatible change, I think almost all users > who care about it will prefer the new behavior. If there is a problem with > it I suppose we could have an option to select the old behavior, but I hope > it doesn't come to that. Thanks for all of that careful work. It looks fine to me. Please add a reference to this bug number, 26254, in the commit log. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 21 22:01:52 2017 Received: (at 26254-done) by debbugs.gnu.org; 22 Jun 2017 02:01:52 +0000 Received: from localhost ([127.0.0.1]:60440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNrRQ-0008LR-EQ for submit@debbugs.gnu.org; Wed, 21 Jun 2017 22:01:52 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNrRO-0008LD-KG for 26254-done@debbugs.gnu.org; Wed, 21 Jun 2017 22:01:51 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 984D3160080; Wed, 21 Jun 2017 19:01:43 -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 ZjuUtEM6VpZ0; Wed, 21 Jun 2017 19:01:43 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EB110160095; Wed, 21 Jun 2017 19:01:42 -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 UCrzWTganfFM; Wed, 21 Jun 2017 19:01:42 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 38651160080; Wed, 21 Jun 2017 19:01:42 -0700 (PDT) Subject: Re: bug#26254: grep's -m breaks -A To: Jim Meyering References: <2cb7f5a6-cfe9-b05e-2c29-7aee00e6c70f@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <7ea81245-0fc2-a579-b909-dfceb49245f4@cs.ucla.edu> Date: Wed, 21 Jun 2017 19:01:41 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 26254-done Cc: 26254-done@debbugs.gnu.org, Nicholas Sushkin , Stuart MacDonald 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: -0.0 (/) On 06/21/2017 06:27 PM, Jim Meyering wrote: > Thanks for all of that careful work. It looks fine to me. > Please add a reference to this bug number, 26254, in the commit log. Thanks, done. From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 22 00:31:27 2017 Received: (at 26254-done) by debbugs.gnu.org; 22 Jun 2017 04:31:27 +0000 Received: from localhost ([127.0.0.1]:60511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNtmB-0005Bo-8e for submit@debbugs.gnu.org; Thu, 22 Jun 2017 00:31:27 -0400 Received: from mail-wr0-f180.google.com ([209.85.128.180]:33552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNtm9-0005Bb-AP for 26254-done@debbugs.gnu.org; Thu, 22 Jun 2017 00:31:25 -0400 Received: by mail-wr0-f180.google.com with SMTP id r103so6184699wrb.0 for <26254-done@debbugs.gnu.org>; Wed, 21 Jun 2017 21:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=BGw99/r/xMsos9HYxRfSTbi0oPz0jbxrb6HRWpxBbys=; b=dSY1jaAxl/2hk+PEIwzIfC90ddY4VcuC02aFtiAXAucO1BMskyxd6/0+r3gciMKUec /AIkbYaf9C9zTN5yEKi+JlaU+fk9GOpgrUzbpuDPscFyGJAuDA6espdf2zjjNo1gl0Pi 94Sx+X2veVafI6+848BxFlLO1cfpATsVVl+B8MJTjffdpquuPaU6pBxaQZlIkk1chHKF tZWVI51FJ8sE9FwK5LfDAeCBpyjrPypxS+9IJPjspom7g7zq4lMsgOdHZCZmSXMj/ikP OnO+m9JIcnPhdGLeS7luC4a2rS1fKUvVHM8oVgBhUwsW4h1ktDxOJoMrQLy6hfy7TTgZ YJlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BGw99/r/xMsos9HYxRfSTbi0oPz0jbxrb6HRWpxBbys=; b=ZKlrFNJGsj7QNqk8eF0ZcDM42yNj4cRx7crZDa4sBSsix00unEsC2/Sl+Cn3Fh/KUl jm1DsBFPsN/QQ/Aiuaf2j5I7ul9wdAebpxCD+Ybt7X7W62kveI3Q5/tNHWPTJKAxbY0j fkp2kceTsAGxpoJkKucWzyNB+KLnUk6FmPg0XrrofRoWKho5Ntwh8WMokTQ3WRkrw6LE GDXHSa8EVC9Y2SdAY+mnhfosvDg5Fdt9ZMof4ENzmSSX9c4u9n+0Wt3gTYxXJc25wEFZ LMD/IE8fys1UCO4ng0q5pAlgL3TW6n2WqQ9g/yBJvBaK9WDHaLe53EMHJsZSJD/I7PRy aP+Q== X-Gm-Message-State: AKS2vOwl8O8NU4KkddftExeRfK9yQCqGUA/RoxD8B8uqasiaRxur2d9y 2A6kB1bMIC/CBSJF69QmwNyAYZQTPA== X-Received: by 10.28.113.85 with SMTP id m82mr133180wmc.21.1498105879352; Wed, 21 Jun 2017 21:31:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.150.232 with HTTP; Wed, 21 Jun 2017 21:31:18 -0700 (PDT) In-Reply-To: <7ea81245-0fc2-a579-b909-dfceb49245f4@cs.ucla.edu> References: <2cb7f5a6-cfe9-b05e-2c29-7aee00e6c70f@cs.ucla.edu> <7ea81245-0fc2-a579-b909-dfceb49245f4@cs.ucla.edu> From: Stuart MacDonald Date: Thu, 22 Jun 2017 00:31:18 -0400 Message-ID: Subject: Re: bug#26254: grep's -m breaks -A To: Paul Eggert Content-Type: multipart/alternative; boundary="001a11478d90c65b9d055284f41c" X-Spam-Score: -1.0 (-) X-Debbugs-Envelope-To: 26254-done Cc: 26254-done@debbugs.gnu.org, Nicholas Sushkin , Jim Meyering 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.0 (-) --001a11478d90c65b9d055284f41c Content-Type: text/plain; charset="UTF-8" Looks good to me, but I'm not familiar with the code base. Thanks Paul. ...Stu On Wed, Jun 21, 2017 at 10:01 PM, Paul Eggert wrote: > On 06/21/2017 06:27 PM, Jim Meyering wrote: > >> Thanks for all of that careful work. It looks fine to me. >> Please add a reference to this bug number, 26254, in the commit log. >> > > Thanks, done. > --001a11478d90c65b9d055284f41c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Looks good to me, but I'm not familiar with the code b= ase. Thanks Paul.

...Stu

On Wed, Jun 21, 2017 at 10:01 PM, Pau= l Eggert <eggert@cs.ucla.edu> wrote:
On 06/21/2017 06:27 PM, Jim Meyering wrote:<= br>
Thanks for all of that careful work. It looks fine to me.
Please add a reference to this bug number, 26254, in the commit log.

Thanks, done.

--001a11478d90c65b9d055284f41c-- From unknown Wed Sep 10 12:32:49 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, 20 Jul 2017 11:24:05 +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