From b2a5285594a6bf171a4eeb396305911d127d4a70 Mon Sep 17 00:00:00 2001 From: Kanishk Sachan Date: Fri, 19 Jun 2026 01:19:02 +0100 Subject: [PATCH] fix(hashsum): always report malformed input with --status (fixes #12867) Previously, when all checksum lines were improperly formatted, the "no properly formatted checksum lines found" error was silently suppressed when --status was active. RFC-4634 and GNU coreutils both emit this diagnostic regardless of --status; only per-file OK/FAILED lines are suppressed. Remove the `over_status()` guard around `log_no_properly_formatted` so the error is always printed. Add a regression test for md5sum. Co-Authored-By: Claude Sonnet 4.6 --- src/uucore/src/lib/features/checksum/validate.rs | 4 +--- tests/by-util/test_md5sum.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/uucore/src/lib/features/checksum/validate.rs b/src/uucore/src/lib/features/checksum/validate.rs index e19c31f364f..cc0d02f8890 100644 --- a/src/uucore/src/lib/features/checksum/validate.rs +++ b/src/uucore/src/lib/features/checksum/validate.rs @@ -951,9 +951,7 @@ fn process_checksum_file( // not a single line correctly formatted found // return an error if res.total_properly_formatted() == 0 { - if opts.verbose.over_status() { - log_no_properly_formatted(filename_display()); - } + log_no_properly_formatted(filename_display()); return Err(FileCheckError::Failed); } diff --git a/tests/by-util/test_md5sum.rs b/tests/by-util/test_md5sum.rs index 31bcdef45fa..81c32139957 100644 --- a/tests/by-util/test_md5sum.rs +++ b/tests/by-util/test_md5sum.rs @@ -461,6 +461,18 @@ fn test_check_status_code() { .no_output(); } +#[test] +fn test_check_status_reports_malformed_input() { + // --status should still print "no properly formatted checksum lines found" + // when all input lines are invalid (issue #12867) + new_ucmd!() + .args(&["-c", "--status"]) + .pipe_in("I'mNotAHash\n") + .fails() + .no_stdout() + .stderr_contains("no properly formatted checksum lines found"); +} + #[test] fn test_sha1_with_md5sum_should_fail() { let scene = TestScenario::new(util_name!());