8000 cksum: fix error message when the flags length and an algorithm different from blake2b are present by Felle33 · Pull Request #7071 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cksum: fix error message when the flags length and an algorithm different from blake2b are present #7071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
};

if ["bsd", "crc", "sysv"].contains(&algo_name) && check {
return Err(ChecksumError::AlgorithmNotSupportedWithCheck.into());
}

let input_length = matches.get_one::<usize>(options::LENGTH);

let length = match input_length {
Expand All @@ -293,6 +289,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
None => None,
};

if ["bsd", "crc", "sysv"].contains(&algo_name) && check {
return Err(ChecksumError::AlgorithmNotSupportedWithCheck.into());
}

if check {
let text_flag = matches.get_flag(options::TEXT);
let binary_flag = matches.get_flag(options::BINARY);
Expand Down
AEF7
12 changes: 12 additions & 0 deletions tests/by-util/test_cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@ fn test_length_not_supported() {
.no_stdout()
.stderr_contains("--length is only supported with --algorithm=blake2b")
.code_is(1);

new_ucmd!()
.arg("-l")
.arg("158")
.arg("-c")
.arg("-a")
.arg("crc")
.arg("/tmp/xxx")
.fails()
.no_stdout()
.stderr_contains("--length is only supported with --algorithm=blake2b")
.code_is(1);
}

#[test]
Expand Down
Loading
0