From a33bc185a5076ea5f6b478ec08b2a806773afb57 Mon Sep 17 00:00:00 2001 From: Stefin Date: Mon, 29 Aug 2022 18:09:02 +0530 Subject: [PATCH] rm: added check for write protected regular empty file Signed-off-by: Stefin --- src/uu/rm/src/rm.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 80f1c8cd9..571a6d2c0 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -420,7 +420,15 @@ fn prompt_write_protected(path: &Path, is_dir: bool, options: &Options) -> bool if is_dir { prompt(&(format!("rm: remove write-protected directory {}? ", path.quote()))) } else { - prompt(&(format!("rm: remove write-protected file {}? ", path.quote()))) + if fs::metadata(path).unwrap().len() == 0 { + return prompt( + &(format!( + "rm: remove write-protected regular empty file {}? ", + path.quote() + )), + ); + } + prompt(&(format!("rm: remove write-protected regular file {}? ", path.quote()))) } } else { true