diff --git a/src/cmd/rm/mod.rs b/src/cmd/rm/mod.rs index e5c45ce..c4688d7 100644 --- a/src/cmd/rm/mod.rs +++ b/src/cmd/rm/mod.rs @@ -266,11 +266,11 @@ impl Action { .and_then(|fd| fd.metadata()) .and_then(|meta| Ok(Filetype::from(meta)))? }; - print!("rm: remove {ft} '{}'? ", &self.path); + eprint!("rm: remove {ft} '{}'? ", &self.path); let mut reply = String::new(); let stdin = io::stdin(); let _read = stdin.read_line(&mut reply); - match reply.as_str() { + match reply.trim_end() { "y" | "Y" | "yes" | "Yes" => Ok(Some(ft)), _ => Ok(None), } @@ -317,14 +317,16 @@ impl AllActions { fn prompt(&self) -> bool { let len = self.items.len(); if len > 3 { - print!("rm: remove {len} arguments? "); - } - let mut reply = String::new(); - let stdin = io::stdin(); - let _read = stdin.read_line(&mut reply); - match reply.as_str() { - "y" | "Y" | "yes" | "Yes" => true, - _ => false, + eprint!("rm: remove {len} arguments? "); + let mut reply = String::new(); + let stdin = io::stdin(); + let _read = stdin.read_line(&mut reply); + match reply.as_str() { + "y" | "Y" | "yes" | "Yes" => true, + _ => false, + } + } else { + true } } }