mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cksum: fix error message when the flags length and an algorithm different from blake2b are present (#7071)
test length and blake2b algorithm before testing supported algorithms
This commit is contained in:
parent
fbea7c41ca
commit
b15bc8440c
2 changed files with 16 additions and 4 deletions
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue