GNU bug report logs - #24024
grep: Mixing "max-count" and "after-context" outputs too few lines

Previous Next

Package: grep;

Reported by: Santiago Ruano Rincón <santiagorr <at> riseup.net>

Date: Tue, 19 Jul 2016 11:55:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24024 in the body.
You can then email your comments to 24024 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#24024; Package grep. (Tue, 19 Jul 2016 11:55:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Santiago Ruano Rincón <santiagorr <at> riseup.net>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Tue, 19 Jul 2016 11:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Santiago Ruano Rincón <santiagorr <at> riseup.net>
To: Igor Bogomazov <ygrex <at> ygrex.ru>, 831673 <at> bugs.debian.org,
 bug-grep <bug-grep <at> gnu.org>
Subject: grep: Mixing "max-count" and "after-context" outputs too few lines
Date: Tue, 19 Jul 2016 13:53:45 +0200
Hi,

Igor Bogomazov <ygrex <at> ygrex.ru> filed the following bug against grep in
Debian.

El 18/07/16 a las 14:30, Igor Bogomazov escribió:
> Package: grep
> Version: 2.25-6
> Severity: normal
> 
> 
> Given after-context=3 it is expected to output at least 4 lines
> as documented, but adding max-count=1 makes it stop on the next
> matching line.
> 
> What I do:
> 
> $ printf '%s\n' a b a c | grep -m1 -A3 a
> 
> What I see:
> 
> a
> b
> 
> What I expect:
> 
> a
> b
> a
> c
> 
> -- System Information:
> Debian Release: stretch/sid
>   APT prefers unstable
>   APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable')
> Architecture: amd64 (x86_64)
> 
> Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)
> Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)
> 
> 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
> 
> grep recommends no packages.
> 
> Versions of packages grep suggests:
> ii  libpcre3  2:8.38-3.1
> 
> -- no debconf information
> 

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




Information forwarded to bug-grep <at> gnu.org:
bug#24024; Package grep. (Tue, 26 Jul 2016 15:39:02 GMT) Full text and rfc822 format available.

Message #8 received at 24024 <at> debbugs.gnu.org (full text, mbox):

From: Norihiro Tanaka <noritnk <at> kcn.ne.jp>
To: Santiago Ruano Rincon <santiagorr <at> riseup.net>
Cc: 24024 <at> debbugs.gnu.org, 831673 <at> bugs.debian.org, ygrex <at> ygrex.ru
Subject: Re: bug#24024: grep: Mixing "max-count" and "after-context" outputs
 too few lines
Date: Wed, 27 Jul 2016 00:38:02 +0900
> Igor Bogomazov <ygrex <at> ygrex.ru> 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.





Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Thu, 08 Sep 2016 05:26:02 GMT) Full text and rfc822 format available.

Notification sent to Santiago Ruano Rincón <santiagorr <at> riseup.net>:
bug acknowledged by developer. (Thu, 08 Sep 2016 05:26:02 GMT) Full text and rfc822 format available.

Message #13 received at 24024-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Santiago Ruano Rincón <santiagorr <at> riseup.net>
Cc: Norihiro Tanaka <noritnk <at> kcn.ne.jp>, 831673 <at> bugs.debian.org,
 24024-done <at> debbugs.gnu.org, ygrex <at> ygrex.ru
Subject: Re: bug#24024: grep: Mixing "max-count" and "after-context" outputs
 too few lines
Date: Wed, 7 Sep 2016 22:25:03 -0700
[Message part 1 (text/plain, inline)]
>> Given after-context=3 it is expected to output at least 4 lines
>> as documented, but adding max-count=1 makes it stop on the next
>> matching line.

Thanks for reporting this. Although grep's behavior is documented ("context does 
not include matching lines" in the node General Output Control) the 
documentation could be clearer and I installed the attached patch.
[0001-doc-define-context-lines.txt (text/plain, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 06 Oct 2016 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 315 days ago.

Previous Next


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