mirror of
git://git.sv.gnu.org/coreutils
synced 2026-05-06 07:06:38 -04:00
sum,cksum: consistently emit detailed write errors
Previously the string from strerror would only be printed for some
algorithms:
$ cksum -a sha2 -l 256 /dev/null > /dev/full
cksum: write error: No space left on device
$ cksum -a sysv /dev/null > /dev/full
cksum: write error
This patch fixes it so that the error information is always printed:
$ ./src/cksum -a sha2 -l 256 /dev/null > /dev/full
cksum: write error: No space left on device
$ ./src/cksum -a sysv /dev/null > /dev/full
cksum: write error: No space left on device
* src/cksum.c (output_file): Don't check for a write error here.
(main): Check for it here instead.
* tests/misc/io-errors.sh: Add a 'cksum' invocation for each supported
algorithm.
https://github.com/coreutils/coreutils/issues/258
This commit is contained in:
+2
-3
@@ -1317,9 +1317,6 @@ output_file (char const *file, int binary_file, void const *digest,
|
||||
}
|
||||
|
||||
putchar (delim);
|
||||
|
||||
if (ferror (stdout))
|
||||
write_error ();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1885,6 +1882,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
DIGEST_OUT (file, binary_file, bin_buffer, raw_digest, prefix_tag,
|
||||
digest_delim, optind != argc, length);
|
||||
if (ferror (stdout))
|
||||
write_error ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,16 @@ echo foo > foo || framework_failure_
|
||||
{
|
||||
printf '%s' "\
|
||||
cat foo
|
||||
cksum -a sysv foo
|
||||
cksum -a bsd foo
|
||||
cksum -a crc foo
|
||||
cksum -a crc32b foo
|
||||
cksum -a md5 foo
|
||||
cksum -a sha1 foo
|
||||
cksum -a sha2 -l 256 foo
|
||||
cksum -a sha3 -l 256 foo
|
||||
cksum -a blake2b foo
|
||||
cksum -a sm3 foo
|
||||
comm foo foo
|
||||
cut -c1- foo
|
||||
cut -f1- foo
|
||||
|
||||
Reference in New Issue
Block a user