GNU bug report logs - #23965
egrep should report line number when failing to parse a file (with -f)

Previous Next

Package: grep;

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

Date: Wed, 13 Jul 2016 09:01:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

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 23965 in the body.
You can then email your comments to 23965 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#23965; Package grep. (Wed, 13 Jul 2016 09:01:02 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. (Wed, 13 Jul 2016 09:01: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: bug-grep <bug-grep <at> gnu.org>
Subject: egrep should report line number when failing to parse a file (with -f)
Date: Wed, 13 Jul 2016 10:59:45 +0200
[Message part 1 (text/plain, inline)]
Hi,

Please find below yet another old-standing bug filed against debian.
grep's behaviour is still the same in 2.25.

https://bugs.debian.org/525214

Cheers,

Santiago

----- Forwarded message from Gunnar Wolf <gwolf <at> gwolf.org> -----

Date: Wed, 22 Apr 2009 18:06:28 -0500
From: Gunnar Wolf <gwolf <at> gwolf.org>
To: Debian Bug Tracking System <submit <at> bugs.debian.org>
Subject: egrep should report line number when failing to parse a file (with -f)
X-Mailer: reportbug 4.1

[...]

egrep -f takes its input from a file. This functionality is often used
i.e. with logcheck, which works basically off a directory full of
files which contain regexes representing log messages to be either
ignored or pushed up - However, when something goes bad and one of
those lines is not parsable, grep won't help in debugging. As an
example, I got loads of log messages such as:

    From: Cron Daemon <root <at> iiec.unam.mx>
    To: root <at> iiec.unam.mx
    Date: Tue, 21 Apr 2009 23:02:02 -0500 (CDT)
    Subject: Cron <logcheck <at> lafa>    if [ -x /usr/sbin/logcheck ]; then nice -n10 /usr/sbin/logcheck; fi

    egrep: Unmatched [ or [^

Finding the file/line where I made this particular mistake was a
tedious job. Users deserve egrep to report the filename and line
number where this error happened.

[...]

----- End forwarded message -----
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#23965; Package grep. (Wed, 20 Jul 2016 22:00:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: Santiago Ruano Rincón <santiagorr <at> riseup.net>
Cc: 23965 <at> debbugs.gnu.org
Subject: Re: bug#23965: egrep should report line number when failing to parse
 a file (with -f)
Date: Wed, 20 Jul 2016 14:58:41 -0700
On Wed, Jul 13, 2016 at 1:59 AM, Santiago Ruano Rincón
<santiagorr <at> riseup.net> wrote:
> Please find below yet another old-standing bug filed against debian.
> grep's behaviour is still the same in 2.25.
>
> https://bugs.debian.org/525214
>
> Cheers,
>
> Santiago
>
> ----- Forwarded message from Gunnar Wolf <gwolf <at> gwolf.org> -----
>
> Date: Wed, 22 Apr 2009 18:06:28 -0500
> From: Gunnar Wolf <gwolf <at> gwolf.org>
> To: Debian Bug Tracking System <submit <at> bugs.debian.org>
> Subject: egrep should report line number when failing to parse a file (with -f)
> X-Mailer: reportbug 4.1
>
> [...]
>
> egrep -f takes its input from a file. This functionality is often used
> i.e. with logcheck, which works basically off a directory full of
> files which contain regexes representing log messages to be either
> ignored or pushed up - However, when something goes bad and one of
> those lines is not parsable, grep won't help in debugging. As an
> example, I got loads of log messages such as:
>
>     From: Cron Daemon <root <at> iiec.unam.mx>
>     To: root <at> iiec.unam.mx
>     Date: Tue, 21 Apr 2009 23:02:02 -0500 (CDT)
>     Subject: Cron <logcheck <at> lafa>    if [ -x /usr/sbin/logcheck ]; then nice -n10 /usr/sbin/logcheck; fi
>
>     egrep: Unmatched [ or [^
>
> Finding the file/line where I made this particular mistake was a
> tedious job. Users deserve egrep to report the filename and line
> number where this error happened.
>
> [...]

Thank you for forwarding that.
I've written a patch to address that. Will post it shortly.




Information forwarded to bug-grep <at> gnu.org:
bug#23965; Package grep. (Sat, 23 Jul 2016 16:32:01 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: Santiago Ruano Rincón <santiagorr <at> riseup.net>
Cc: 23965 <at> debbugs.gnu.org
Subject: Re: bug#23965: egrep should report line number when failing to parse
 a file (with -f)
Date: Sat, 23 Jul 2016 09:31:01 -0700
[Message part 1 (text/plain, inline)]
On Wed, Jul 20, 2016 at 2:58 PM, Jim Meyering <jim <at> meyering.net> wrote:
> On Wed, Jul 13, 2016 at 1:59 AM, Santiago Ruano Rincón
> <santiagorr <at> riseup.net> wrote:
>> Please find below yet another old-standing bug filed against debian.
>> grep's behaviour is still the same in 2.25.
>>
>> https://bugs.debian.org/525214
>>
>> Cheers,
>>
>> Santiago
>>
>> ----- Forwarded message from Gunnar Wolf <gwolf <at> gwolf.org> -----
>>
>> Date: Wed, 22 Apr 2009 18:06:28 -0500
>> From: Gunnar Wolf <gwolf <at> gwolf.org>
>> To: Debian Bug Tracking System <submit <at> bugs.debian.org>
>> Subject: egrep should report line number when failing to parse a file (with -f)
>> X-Mailer: reportbug 4.1
>>
>> [...]
>>
>> egrep -f takes its input from a file. This functionality is often used
>> i.e. with logcheck, which works basically off a directory full of
>> files which contain regexes representing log messages to be either
>> ignored or pushed up - However, when something goes bad and one of
>> those lines is not parsable, grep won't help in debugging. As an
>> example, I got loads of log messages such as:
>>
>>     From: Cron Daemon <root <at> iiec.unam.mx>
>>     To: root <at> iiec.unam.mx
>>     Date: Tue, 21 Apr 2009 23:02:02 -0500 (CDT)
>>     Subject: Cron <logcheck <at> lafa>    if [ -x /usr/sbin/logcheck ]; then nice -n10 /usr/sbin/logcheck; fi
>>
>>     egrep: Unmatched [ or [^
>>
>> Finding the file/line where I made this particular mistake was a
>> tedious job. Users deserve egrep to report the filename and line
>> number where this error happened.
>>
>> [...]
>
> Thank you for forwarding that.
> I've written a patch to address that. Will post it shortly.

Here are two patches.
The first adds coreutils' perl-based test harness to grep.
The second improves those diagnostics and adds a test using the new harness:

    grep: print "filename:lineno:" in invalid-regex diagnostic

    Determining the file name and line number is a little tricky because
    of the way the regular expressions are all concatenated onto a newline-
    separated list.  By the time grep would compiling regular expressions,
    the <filename,lineno> origin of each regexp was no longer available.
    This patch adds a list of filename,first_lineno pairs, one per input
    source, by which we can then map the ordinal regexp number to a
    filename,lineno pair for the diagnostic.

    * src/dfasearch.c (GEAcompile): When diagnosing an invalid regexp
    specified via -f FILE, include the "FILENAME:LINENO: " prefix.
    Also, when there are two or more lines with compilation failures,
    diagnose all of them, rather than stopping after the first.
    * src/grep.h (pattern_file_name): Declare it.
    * src/grep.c: (struct FL_pair): Define type.
    (fl_pair, n_fl_pair_slots, n_pattern_files, patfile_lineno):
    Define globals.
    (fl_add, pattern_file_name): Define functions.
    (main): Call fl_add for each type of the following: -e argument,
    -f argument, command-line-specified (without -e) regexp.
    * tests/filename-lineno.pl: New file.
    * tests/Makefile.am (TESTS): Add it.
    * NEWS (Improvements): Mention this.
    Initially reported by Gunnar Wolf in https://bugs.debian.org/525214
    Forwarded to grep's bug list by Santiago Ruano Rincón as
    http://debbugs.gnu.org/23965
[filename-lineno.diff (text/plain, attachment)]

Information forwarded to bug-grep <at> gnu.org:
bug#23965; Package grep. (Mon, 25 Jul 2016 18:57:02 GMT) Full text and rfc822 format available.

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

From: Santiago Ruano Rincón <santiagorr <at> riseup.net>
To: Jim Meyering <jim <at> meyering.net>
Cc: 525214 <at> bugs.debian.org, 23965 <at> debbugs.gnu.org
Subject: Re: bug#23965: egrep should report line number when failing to parse
 a file (with -f)
Date: Mon, 25 Jul 2016 20:56:39 +0200
El 23/07/16 a las 09:31, Jim Meyering escribió:
> On Wed, Jul 20, 2016 at 2:58 PM, Jim Meyering <jim <at> meyering.net> wrote:
> > On Wed, Jul 13, 2016 at 1:59 AM, Santiago Ruano Rincón
> > <santiagorr <at> riseup.net> wrote:

…

> Here are two patches.
> The first adds coreutils' perl-based test harness to grep.
> The second improves those diagnostics and adds a test using the new harness:

Thanks!

I will include it in the next grep debian release.

Cheers,

Santiago




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Tue, 26 Jul 2016 06:02:01 GMT) Full text and rfc822 format available.

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

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

From: Jim Meyering <jim <at> meyering.net>
To: Santiago Ruano Rincón <santiagorr <at> riseup.net>
Cc: 525214-done <at> bugs.debian.org, 23965-done <at> debbugs.gnu.org
Subject: Re: bug#23965: egrep should report line number when failing to parse
 a file (with -f)
Date: Mon, 25 Jul 2016 23:00:35 -0700
On Mon, Jul 25, 2016 at 11:56 AM, Santiago Ruano Rincón
<santiagorr <at> riseup.net> wrote:
> El 23/07/16 a las 09:31, Jim Meyering escribió:
>> On Wed, Jul 20, 2016 at 2:58 PM, Jim Meyering <jim <at> meyering.net> wrote:
>> > On Wed, Jul 13, 2016 at 1:59 AM, Santiago Ruano Rincón
>> > <santiagorr <at> riseup.net> wrote:
>
> …
>
>> Here are two patches.
>> The first adds coreutils' perl-based test harness to grep.
>> The second improves those diagnostics and adds a test using the new harness:
>
> Thanks!
>
> I will include it in the next grep debian release.

Nice.
I've added a couple more tests and pushed as
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=f13c169e13aed279baa00d9ced9d93fe24775493




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

This bug report was last modified 7 years and 241 days ago.

Previous Next


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