Skip to content
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
6 changes: 5 additions & 1 deletion src/uu/hashsum/src/hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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());
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/uucore/src/lib/features/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
13 changes: 13 additions & 0 deletions tests/by-util/test_hashsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading