]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cksum: validate options more consistently
authorPádraig Brady <P@draigBrady.com>
Thu, 8 Jan 2026 14:07:32 +0000 (14:07 +0000)
committerPádraig Brady <P@draigBrady.com>
Thu, 8 Jan 2026 16:14:57 +0000 (16:14 +0000)
commit9200747f65e3523f7b48184a331eec5a1225b435
tree515c42278934cfa28c794b03d4f2f3eb9c935024
parent9a388638851aff251ff7c56388eb11eb4fea7b81
cksum: validate options more consistently

We disallow `cksum --tag --check` which is fine,
but the error should be consistent with md5sum,
and less confusing, as it currently mentions
"--binary" and "--text" which weren't specified.

We disallow `cksum --tag --text` which is fine,
but we should also disallow `cksum --text --tag`.

We should honor an explicit --binary (output *)
with this combination of options:
cksum --binary --tag --untagged -a md5 /dev/null

Note this also makes both of `cksum -a md5` and
`cksum --tag -a md5` consistently use binary mode
when reading from a tty on systems like MinGW
where O_BINARY is set.

* src/cksum.c (main): Adjust --text,--binary
and --tag,--untagged option processing.
* tests/cksum/cksum-a.sh: Add test cases.
* tests/cksum/cksum-c.sh: Likewise.
* NEWS: Mention the improvement.
Fixes https://github.com/coreutils/coreutils/issues/163
NEWS
src/cksum.c
tests/cksum/cksum-a.sh
tests/cksum/cksum-c.sh