diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index c7fed55b086..1c24910e488 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -542,12 +542,9 @@ fn wipe_file( ); } // size is an optional argument for exactly how many bytes we want to shred - // Ignore failed writes; just keep trying - show_if_err!( - do_pass(&mut file, &pass_type, exact, random_source, size).map_err_context(|| { - translate!("shred-file-write-pass-failed", "file" => path.maybe_quote()) - }) - ); + do_pass(&mut file, &pass_type, exact, random_source, size).map_err_context( + || translate!("shred-file-write-pass-failed", "file" => path.maybe_quote()), + )?; } if remove_method != RemoveMethod::None { diff --git a/tests/by-util/test_shred.rs b/tests/by-util/test_shred.rs index aa95a769ae1..afdcca64fba 100644 --- a/tests/by-util/test_shred.rs +++ b/tests/by-util/test_shred.rs @@ -279,7 +279,6 @@ fn test_random_source_regular_file() { } #[test] -#[ignore = "known issue #7947"] fn test_random_source_dir() { let (at, mut ucmd) = at_and_ucmd!(); @@ -287,12 +286,17 @@ fn test_random_source_dir() { let file = "foo.txt"; at.write(file, "a"); - ucmd - .arg("-v") + // The test verifies that shred stops immediately on error instead of continuing + // Platform differences: + // - Unix: Error during write ("File write pass failed: Is a directory") + // - Windows: Error during open ("cannot open random source") + // Both are correct - key is NOT seeing "pass 2/3" (which proves it stopped) + ucmd.arg("-v") .arg("--random-source=source") .arg(file) .fails() - .stderr_only("shred: foo.txt: pass 1/3 (random)...\nshred: foo.txt: File write pass failed: Is a directory\n"); + .stderr_does_not_contain("pass 2/3") + .stderr_does_not_contain("pass 3/3"); } #[test]