GNU bug report logs - #22816
cmp --verbose EOF message could be more verbose

Previous Next

Package: diffutils;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Fri, 26 Feb 2016 09:54: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 22816 in the body.
You can then email your comments to 22816 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-diffutils <at> gnu.org:
bug#22816; Package diffutils. (Fri, 26 Feb 2016 09:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Fri, 26 Feb 2016 09:54:02 GMT) Full text and rfc822 format available.

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

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-diffutils <at> gnu.org
Subject: cmp --verbose EOF message could be more verbose
Date: Fri, 26 Feb 2016 17:53:07 +0800
One would think the "cmp: EOF on SHORTER-FILE" message
should at least say what line number if --verbose or --print-bytes is given.




Information forwarded to bug-diffutils <at> gnu.org:
bug#22816; Package diffutils. (Sun, 01 May 2016 02:56:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 22816 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#22816: cmp --verbose EOF message could be
 more verbose
Date: Sat, 30 Apr 2016 19:55:21 -0700
On Fri, Feb 26, 2016 at 1:53 AM, 積丹尼 Dan Jacobson <jidanni <at> jidanni.org> wrote:
> One would think the "cmp: EOF on SHORTER-FILE" message
> should at least say what line number if --verbose or --print-bytes is given.

Good idea.
Patch welcome, but it need not hold up a release.




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Thu, 04 May 2017 17:30:03 GMT) Full text and rfc822 format available.

Notification sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
bug acknowledged by developer. (Thu, 04 May 2017 17:30:03 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: 22816-done <at> debbugs.gnu.org, Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: cmp --verbose EOF message could be more verbose
Date: Thu, 4 May 2017 10:28:51 -0700
tags 22816 + wontfix
done

Re https://debbugs.gnu.org/22816, I realized that printing any line
number upon EOF would necessitate counting them from the start, and I
would rather not do that.

If you encounter EOF in this case and want to know how many newlines
were in one of those inputs, you can run "wc -l" on that input.

Making cmp perform that task does not seem worthwhile, because one
would have to choose between always counting newlines (like wc -l
does), and thus incurring this added cost all the time, or accepting a
partial (and racy) solution of rereading the regular file upon EOF. I
say "partial" because if the input is not seekable, that is not even
possible. And "racy" because once rewound and reread, we may then be
processing different content.

So I'm closing this as WONTFIX.




Added tag(s) wontfix. Request was from Jim Meyering <jim <at> meyering.net> to control <at> debbugs.gnu.org. (Thu, 04 May 2017 17:42:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-diffutils <at> gnu.org:
bug#22816; Package diffutils. (Fri, 05 May 2017 00:25:01 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: jim <at> meyering.net
Cc: 22816 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: [bug-diffutils] bug#22816: cmp --verbose EOF message could be
 more verbose
Date: Thu, 4 May 2017 17:24:19 -0700
[Message part 1 (text/plain, inline)]
On 05/04/2017 10:28 AM, Jim Meyering wrote:
> Making cmp perform that task does not seem worthwhile, because one
> would have to choose between always counting newlines (like wc -l
> does), and thus incurring this added cost all the time, or accepting a
> partial (and racy) solution of rereading the regular file upon EOF.

There's a third way, that satisfies Dan Jacobson's request in the usual 
case, without incurring added cost. Proposed patch attached, with a 
simple test for 'cmp' (which is a good thing to have in any event).

[0001-cmp-report-prefix-length-when-one-file-is-shorter.patch (text/x-patch, attachment)]

Information forwarded to bug-diffutils <at> gnu.org:
bug#22816; Package diffutils. (Fri, 05 May 2017 01:15:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 22816 <at> debbugs.gnu.org, Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: [bug-diffutils] bug#22816: cmp --verbose EOF message could be
 more verbose
Date: Thu, 4 May 2017 18:14:17 -0700
On Thu, May 4, 2017 at 5:24 PM, Paul Eggert <eggert <at> cs.ucla.edu> wrote:
> On 05/04/2017 10:28 AM, Jim Meyering wrote:
>>
>> Making cmp perform that task does not seem worthwhile, because one
>> would have to choose between always counting newlines (like wc -l
>> does), and thus incurring this added cost all the time, or accepting a
>> partial (and racy) solution of rereading the regular file upon EOF.
>
>
> There's a third way, that satisfies Dan Jacobson's request in the usual
> case, without incurring added cost. Proposed patch attached, with a simple
> test for 'cmp' (which is a good thing to have in any event).

Oh! Glad you did that. I (now) see that cmp already did compute line numbers.
Thanks a lot for adding the tests, too.

My only question is whether to print zero-indexed line and byte
numbers. I think most people will interpret "after byte 5, line 1" as
the 5th byte on the first line, but with that patch, it means the 6th
byte on the second line.
I.e., what should this print?

  cmp <(printf '1\nfoo') <(printf '1\nfoolery\n')




Information forwarded to bug-diffutils <at> gnu.org:
bug#22816; Package diffutils. (Fri, 05 May 2017 15:02:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Jim Meyering <jim <at> meyering.net>
Cc: 22816 <at> debbugs.gnu.org, Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: [bug-diffutils] bug#22816: cmp --verbose EOF message could be
 more verbose
Date: Fri, 5 May 2017 08:01:16 -0700
[Message part 1 (text/plain, inline)]
Jim Meyering wrote:
> what should this print?
>
>   cmp <(printf '1\nfoo') <(printf '1\nfoolery\n')

Good point, I didn't think of that.  Also, now that I think about it more, a 
diagnostic ending in "after byte 0, line 0" is confusing in a command that 
ordinarily uses origin-1 offsets.

I installed the attached further patch.  With it, your example now outputs:

cmp: EOF on /dev/fd/63 after byte 5, line 2

This is more consistent with longstanding behavior:

$ cmp <(printf '1\nfoot') <(printf '1\nfoolery\n')
/dev/fd/63 /dev/fd/62 differ: byte 6, line 2
[0001-cmp-improve-EOF-diagnostic.patch (text/x-diff, attachment)]

Removed tag(s) wontfix. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Fri, 05 May 2017 15:03:02 GMT) Full text and rfc822 format available.

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

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

Previous Next


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