bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9956: Linux program "sum"


From: Pádraig Brady
Subject: bug#9956: Linux program "sum"
Date: Mon, 07 Nov 2011 00:22:54 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]