On Sat, Feb 4, 2023 at 10:01 AM Pádraig Brady <p...@draigbrady.com> wrote: > > On 04/02/2023 16:58, Jim Meyering wrote: > > On Sat, Feb 4, 2023 at 5:52 AM Pádraig Brady <p...@draigbrady.com> wrote: > >> > >> --raw output is the most composable format, and also is a > >> robust way to discard the file name without parsing (escaped) output. > > > > Very nice. I applied it and ran all tests, and distcheck. All passed. > > TIny suggestions: > > > >> diff --git a/doc/coreutils.texi b/doc/coreutils.texi > >> index 4d7d9439d..536301d63 100644 > >> --- a/doc/coreutils.texi > >> +++ b/doc/coreutils.texi > >> @@ -4059,6 +4059,14 @@ input digest string as what is output. I.e., > >> removing or adding any > >> @opindex --debug > >> Output extra information to stderr, like the checksum implementation > >> being used. > >> > >> +@item --raw > >> +@opindex --raw > >> +@cindex raw binary checksum > >> +Print an unencoded raw binary digest, not hexadecimal. > >> +No file name or other information is output in this mode. > >> +Bytes are output in network byte order (big endian). > >> +This option is ignored with @option{--check}. > > > > Maybe insert "only" and use active voice, and do mention the "only one > > input" limit: > > > > Print only the unencoded raw binary digest for a single file. > > Do not output the file name or anything else. > > Use network byte order (big endian) where applicable: for bsd, crc and > > sysv. > > This option is ignored with @option{--check} and works only with a > > single input. > > Much better, thanks. > > > Is it worth saying explicitly that unlike other output formats, cksum > > provides no way to check a --raw checksum? > > Yes. I'll change your last line to: > > This option works only with a single input. > Unlike other output formats, cksum provides no way to --check a --raw > checksum.
I noticed a sporadic test failure when the bsd checksum happened to have one or more leading zeros. Compare these: $ src/cksum --raw --algorithm=bsd <<< 2|od --endian=big -An -w1024 -tu2|tr -d ' ' 35 $ src/cksum --untagged --algorithm=bsd <<< 2 00035 1 At first I thought I'd strip the excess zeros before comparing, but thought it slightly better to zero-pad any too-narrow value. The attached seems to do the job:
cksum-raw-zero-padding.diff
Description: Binary data