GNU bug report logs - #9956
Linux program "sum"

Previous Next

Package: coreutils;

Reported by: Rodney Rieck <rodneyrieck <at> suddenlink.net>

Date: Fri, 4 Nov 2011 19:15:01 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

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 9956 in the body.
You can then email your comments to 9956 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-coreutils <at> gnu.org:
bug#9956; Package coreutils. (Fri, 04 Nov 2011 19:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rodney Rieck <rodneyrieck <at> suddenlink.net>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 04 Nov 2011 19:15:02 GMT) Full text and rfc822 format available.

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

From: Rodney Rieck <rodneyrieck <at> suddenlink.net>
To: <bug-coreutils <at> gnu.org>
Subject: Linux program "sum"
Date: Fri, 4 Nov 2011 13:37:34 -0500
[Message part 1 (text/html, inline)]

Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Fri, 04 Nov 2011 20:00:04 GMT) Full text and rfc822 format available.

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Fri, 04 Nov 2011 20:00:05 GMT) Full text and rfc822 format available.

Notification sent to Rodney Rieck <rodneyrieck <at> suddenlink.net>:
bug acknowledged by developer. (Fri, 04 Nov 2011 20:00:06 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: Rodney Rieck <rodneyrieck <at> suddenlink.net>
Cc: 9956-done <at> debbugs.gnu.org
Subject: Re: bug#9956: Linux program "sum"
Date: Fri, 04 Nov 2011 13:56:59 -0600
tag 9956 notabug
thanks

On 11/04/2011 12:37 PM, Rodney Rieck wrote:
>     If you type in something like this:  sum -r *
>
>     and if there are multiple files present in the current directory, you
>     will get output like this for each file it checks:
>
>     [check_sum] [number_of_blocks] [file_name]
>
>     If though on the command line you change the "*" to a single file name,
>     the output is the same except that it doesn't print/display the
>     "[file_name]", I guess because that seems redundant because the file
>     name is already known and was typed in on the command line.

Thanks for the report.  If you want 'sum' to output the file name, even 
for one file, then use 'sum --sysv' (or sum -s), although that alters 
the output to strip leading zeroes and use slightly different spacing:

$ sum a
00000     0 a
$ sum -s a
0 0 a

Since this feature is already implemented, I'm closing out this bug report.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




Information forwarded to bug-coreutils <at> gnu.org:
bug#9956; Package coreutils. (Sun, 06 Nov 2011 08:41:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: 9956 <at> debbugs.gnu.org
Cc: eblake <at> redhat.com
Subject: Re: bug#9956: Linux program "sum"
Date: Sun, 06 Nov 2011 09:38:05 +0100
Eric Blake wrote:
> On 11/04/2011 12:37 PM, Rodney Rieck wrote:
>>     If you type in something like this:  sum -r *
>>
>>     and if there are multiple files present in the current directory, you
>>     will get output like this for each file it checks:
>>
>>     [check_sum] [number_of_blocks] [file_name]
>>
>>     If though on the command line you change the "*" to a single file name,
>>     the output is the same except that it doesn't print/display the
>>     "[file_name]", I guess because that seems redundant because the file
>>     name is already known and was typed in on the command line.
>
> Thanks for the report.  If you want 'sum' to output the file name,
> even for one file, then use 'sum --sysv' (or sum -s), although that
> alters the output to strip leading zeroes and use slightly different
> spacing:
>
> $ sum a
> 00000     0 a
> $ sum -s a
> 0 0 a
>
> Since this feature is already implemented, I'm closing out this bug report.

Note that if you really do want sum's default checksum algorithm, then
you do not want to add the --sysv option, since that usually results
in a different checksum:

    $ echo foo > k
    $ sum k; sum -s k
    00106     1
    334 1 k

Depending on your application, if you're not particularly attached
to sum's checksum algorithm, then you may want to use sha1sum instead.




Information forwarded to bug-coreutils <at> gnu.org:
bug#9956; Package coreutils. (Sun, 06 Nov 2011 13:04:01 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Rodney Rieck <rodneyrieck <at> suddenlink.net>
Cc: 9956 <at> debbugs.gnu.org
Subject: Re: bug#9956: Linux program "sum"
Date: Sun, 06 Nov 2011 13:00:50 +0000
On 11/04/2011 06:37 PM, Rodney Rieck wrote:
>    Hello,
> 
> 
> 
>    This is about the Linux program "sum" that computes checksums and
>    number of blocks in a file.  I'm not writing about a program error I've
>    found -- I am writing about how the output from the program is
>    formatted.
> 
>    If you type in something like this:  sum -r *
> 
>    and if there are multiple files present in the current directory, you
>    will get output like this for each file it checks:
> 
>    [check_sum] [number_of_blocks] [file_name]
> 
>    If though on the command line you change the "*" to a single file name,
>    the output is the same except that it doesn't print/display the
>    "[file_name]", I guess because that seems redundant because the file
>    name is already known and was typed in on the command line.

I consider that a bug.
freebsd always outputs the file name for example.
This means that if you do `find -type f | xargs sum`,
the last entry could be without a file name.

Now we can't change without consideration for backwards compat,
though I'd be inclined to fix this inconsistency.

cheers,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#9956; Package coreutils. (Sun, 06 Nov 2011 13:16:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 9956 <at> debbugs.gnu.org, Rodney Rieck <rodneyrieck <at> suddenlink.net>
Subject: Re: bug#9956: Linux program "sum"
Date: Sun, 06 Nov 2011 14:12:56 +0100
Pádraig Brady wrote:
> On 11/04/2011 06:37 PM, Rodney Rieck wrote:
>>    Hello,
>>
>>    This is about the Linux program "sum" that computes checksums and
>>    number of blocks in a file.  I'm not writing about a program error I've
>>    found -- I am writing about how the output from the program is
>>    formatted.
>>
>>    If you type in something like this:  sum -r *
>>
>>    and if there are multiple files present in the current directory, you
>>    will get output like this for each file it checks:
>>
>>    [check_sum] [number_of_blocks] [file_name]
>>
>>    If though on the command line you change the "*" to a single file name,
>>    the output is the same except that it doesn't print/display the
>>    "[file_name]", I guess because that seems redundant because the file
>>    name is already known and was typed in on the command line.
>
> I consider that a bug.
> freebsd always outputs the file name for example.
> This means that if you do `find -type f | xargs sum`,
> the last entry could be without a file name.
>
> Now we can't change without consideration for backwards compat,
> though I'd be inclined to fix this inconsistency.

The existing behavior is compatible with that of UCB sum,
and -r (the default) selects BSD compatibility:

    solaris10$ : > k && /usr/ucb/sum k
    00000     0
    solaris10$ /usr/ucb/sum k k
    00000     0 k
    00000     0 k

Since GNU sum's raison d'etre is compatibility, I'd have a hard
time justifying a change that would render it incompatible.




Information forwarded to bug-coreutils <at> gnu.org:
bug#9956; Package coreutils. (Mon, 07 Nov 2011 00:26:01 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 9956 <at> debbugs.gnu.org, Rodney Rieck <rodneyrieck <at> suddenlink.net>
Subject: Re: bug#9956: Linux program "sum"
Date: Mon, 07 Nov 2011 00:22:54 +0000
On 11/06/2011 01:12 PM, Jim Meyering wrote:
> Pádraig Brady wrote:
>> On 11/04/2011 06:37 PM, Rodney Rieck wrote:
>>>    Hello,
>>>
>>>    This is about the Linux program "sum" that computes checksums and
>>>    number of blocks in a file.  I'm not writing about a program error I've
>>>    found -- I am writing about how the output from the program is
>>>    formatted.
>>>
>>>    If you type in something like this:  sum -r *
>>>
>>>    and if there are multiple files present in the current directory, you
>>>    will get output like this for each file it checks:
>>>
>>>    [check_sum] [number_of_blocks] [file_name]
>>>
>>>    If though on the command line you change the "*" to a single file name,
>>>    the output is the same except that it doesn't print/display the
>>>    "[file_name]", I guess because that seems redundant because the file
>>>    name is already known and was typed in on the command line.
>>
>> I consider that a bug.
>> freebsd always outputs the file name for example.
>> This means that if you do `find -type f | xargs sum`,
>> the last entry could be without a file name.
>>
>> Now we can't change without consideration for backwards compat,
>> though I'd be inclined to fix this inconsistency.
> 
> The existing behavior is compatible with that of UCB sum,
> and -r (the default) selects BSD compatibility:
> 
>     solaris10$ : > k && /usr/ucb/sum k
>     00000     0
>     solaris10$ /usr/ucb/sum k k
>     00000     0 k
>     00000     0 k
> 
> Since GNU sum's raison d'etre is compatibility, I'd have a hard
> time justifying a change that would render it incompatible.
> 

Interesting. On solaris:

$ echo 1 > 1
$ sum -r 1
32802      1 1
$ /usr/ucb/sum 1
32802     1

UCB being the "Berkley" variant.
However BSD changed to always outputting the filename at some stage
because `sum` does so on FreeBSD, and has since 1993 according to
  http://svnweb.freebsd.org/base/head/usr.bin/cksum/

This suggests that the UCB variant was added to solaris around 1989
  http://src.illumos.org/source/xref/illumos-gate/usr/src/ucbcmd/sum/sum.c

So I'm guessing this was changed in the BSD source sometime
between 1989 and 1993.


cheers,
Pádraig.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 05 Dec 2011 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 198 days ago.

Previous Next


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