aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--doc/coreutils.texi6
-rw-r--r--src/sum.c4
-rwxr-xr-xtests/misc/sum.pl18
4 files changed, 16 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index efdb1450e..d9ab04529 100644
--- a/NEWS
+++ b/NEWS
@@ -83,6 +83,9 @@ GNU coreutils NEWS -*- outline -*-
stat will use decomposed (major,minor) device numbers in its default format.
This is less ambiguous, and more consistent with ls.
+ sum [-r] will output a file name, even if only a single name is passed.
+ This is consistent with sum -s, cksum, and other sum(1) implementations.
+
** New Features
expr and factor now support bignums on all platforms.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index a435ed63e..5c12298cf 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -3887,10 +3887,8 @@ sum [@var{option}]@dots{} [@var{file}]@dots{}
@end example
@command{sum} prints the checksum for each @var{file} followed by the
-number of blocks in the file (rounded up). If more than one @var{file}
-is given, file names are also printed (by default). (With the
-@option{--sysv} option, corresponding file names are printed when there is
-at least one file argument.)
+number of blocks in the file (rounded up). If at least one @var{file}
+is given, file names are also printed.
By default, GNU @command{sum} computes checksums using an algorithm
compatible with BSD @command{sum} and prints file sizes in units of
diff --git a/src/sum.c b/src/sum.c
index c17af3f6b..018623d47 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -80,7 +80,7 @@ Print checksum and block counts for each FILE.\n\
/* Calculate and print the rotated checksum and the size in 1K blocks
of file FILE, or of the standard input if FILE is "-".
- If PRINT_NAME is >1, print FILE next to the checksum and size.
+ If PRINT_NAME is >0, print FILE next to the checksum and size.
The checksum varies depending on sizeof (int).
Return true if successful. */
@@ -135,7 +135,7 @@ bsd_sum_file (char const *file, int print_name)
printf ("%05d %5s", checksum,
human_readable (total_bytes, hbuf, human_ceiling, 1, 1024));
- if (print_name > 1)
+ if (print_name)
printf (" %s", file);
putchar ('\n');
diff --git a/tests/misc/sum.pl b/tests/misc/sum.pl
index 0b737c4e6..0b0f88189 100755
--- a/tests/misc/sum.pl
+++ b/tests/misc/sum.pl
@@ -28,18 +28,18 @@ my $in_2k = 'b' x 2048;
my @Tests =
(
- ['1', {IN=> {f=> ''}}, {OUT=>"00000 0\n"}],
- ['2', {IN=> {f=> 'a'}}, {OUT=>"00097 1\n"}],
- ['3', {IN=> {f=> 'abc'}}, {OUT=>"16556 1\n"}],
- ['4', {IN=> {f=> 'message digest'}}, {OUT=>"26423 1\n"}],
- ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"53553 1\n"}],
+ ['1', {IN=> {f=> ''}}, {OUT=>"00000 0 f\n"}],
+ ['2', {IN=> {f=> 'a'}}, {OUT=>"00097 1 f\n"}],
+ ['3', {IN=> {f=> 'abc'}}, {OUT=>"16556 1 f\n"}],
+ ['4', {IN=> {f=> 'message digest'}}, {OUT=>"26423 1 f\n"}],
+ ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"53553 1 f\n"}],
['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}},
- {OUT=>"25587 1\n"}],
- ['7', {IN=> {f=> '1234567890' x 8}}, {OUT=>"21845 1\n"}],
+ {OUT=>"25587 1 f\n"}],
+ ['7', {IN=> {f=> '1234567890' x 8}}, {OUT=>"21845 1 f\n"}],
- ['a-r-1k', '-r', {IN=> {f=> $in_1k}}, {OUT=>"65409 1\n"}],
+ ['a-r-1k', '-r', {IN=> {f=> $in_1k}}, {OUT=>"65409 1 f\n"}],
['a-s-1k', '-s', {IN=> {f=> $in_1k}}, {OUT=>"33793 2 f\n"}],
- ['b-r-2k', '-r', {IN=> {f=> $in_2k}}, {OUT=>"65223 2\n"}],
+ ['b-r-2k', '-r', {IN=> {f=> $in_2k}}, {OUT=>"65223 2 f\n"}],
['b-s-2k', '-s', {IN=> {f=> $in_2k}}, {OUT=>"4099 4 f\n"}],
['1s', '-s', {IN=> {f=> ''}}, {OUT=>"0 0 f\n"}],