diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 12cd67acd..5265f29f0 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -365,6 +365,7 @@ fn get_size(size_str_opt: Option) -> Option { .or_else(|| { if let Some(size) = size_str_opt { show_error!("invalid file size: {}", size.quote()); + // TODO: replace with our error management std::process::exit(1); } None @@ -578,7 +579,8 @@ fn wipe_name(orig_path: &Path, verbose: bool, remove_method: RemoveMethod) -> Op new_path.quote(), e ); - return None; + // TODO: replace with our error management + std::process::exit(1); } } } diff --git a/tests/by-util/test_shred.rs b/tests/by-util/test_shred.rs index 03aeef0c4..8dfd403b7 100644 --- a/tests/by-util/test_shred.rs +++ b/tests/by-util/test_shred.rs @@ -6,6 +6,7 @@ // spell-checker:ignore wipesync use crate::common::util::TestScenario; +use std::path::Path; #[test] fn test_invalid_arg() { @@ -163,3 +164,26 @@ fn test_shred_empty() { assert!(!at.file_exists(file_a)); } + +#[test] +#[cfg(all(unix, feature = "chmod"))] +fn test_shred_fail_no_perm() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let dir = "dir"; + + let file = "test_shred_remove_a"; + + let binding = Path::new("dir").join(file); + let path = binding.to_str().unwrap(); + at.mkdir(dir); + at.touch(path); + scene.ccmd("chmod").arg("a-w").arg(dir).succeeds(); + + scene + .ucmd() + .arg("-uv") + .arg(path) + .fails() + .stderr_contains("Couldn't rename to"); +}