mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #6584 from howjmay/checksum-no-check
hashsum: Return err when only --strict or --quiet is given
This commit is contained in:
commit
79d7158aac
3 changed files with 22 additions and 1 deletions
|
@ -209,6 +209,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
|||
let check = matches.get_flag("check");
|
||||
let status = matches.get_flag("status");
|
||||
let quiet = matches.get_flag("quiet") || status;
|
||||
let strict = matches.get_flag("strict");
|
||||
let warn = matches.get_flag("warn") && !status;
|
||||
let ignore_missing = matches.get_flag("ignore-missing");
|
||||
|
||||
|
@ -220,7 +221,6 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
|||
if check {
|
||||
let text_flag = matches.get_flag("text");
|
||||
let binary_flag = matches.get_flag("binary");
|
||||
let strict = matches.get_flag("strict");
|
||||
|
||||
if binary_flag || text_flag {
|
||||
return Err(ChecksumError::BinaryTextConflict.into());
|
||||
|
@ -245,6 +245,10 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
|||
Some(algo.name),
|
||||
Some(algo.bits),
|
||||
);
|
||||
} else if quiet {
|
||||
return Err(ChecksumError::QuietNotCheck.into());
|
||||
} else if strict {
|
||||
return Err(ChecksumError::StrictNotCheck.into());
|
||||
}
|
||||
|
||||
let nonames = *matches
|
||||
|
|
|
@ -81,6 +81,10 @@ pub enum ChecksumError {
|
|||
RawMultipleFiles,
|
||||
#[error("the --ignore-missing option is meaningful only when verifying checksums")]
|
||||
IgnoreNotCheck,
|
||||
#[error("the --strict option is meaningful only when verifying checksums")]
|
||||
StrictNotCheck,
|
||||
#[error("the --quiet option is meaningful only when verifying checksums")]
|
||||
QuietNotCheck,
|
||||
#[error("Invalid output size for SHA3 (expected 224, 256, 384, or 512)")]
|
||||
InvalidOutputSizeForSha3,
|
||||
#[error("--bits required for SHA3")]
|
||||
|
|
|
@ -874,6 +874,19 @@ fn test_check_quiet() {
|
|||
.fails()
|
||||
.stdout_contains("f: FAILED")
|
||||
.stderr_contains("WARNING: 1 computed checksum did NOT match");
|
||||
|
||||
scene
|
||||
.ccmd("md5sum")
|
||||
.arg("--quiet")
|
||||
.arg(at.subdir.join("in.md5"))
|
||||
.fails()
|
||||
.stderr_contains("md5sum: the --quiet option is meaningful only when verifying checksums");
|
||||
scene
|
||||
.ccmd("md5sum")
|
||||
.arg("--strict")
|
||||
.arg(at.subdir.join("in.md5"))
|
||||
.fails()
|
||||
.stderr_contains("md5sum: the --strict option is meaningful only when verifying checksums");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue