rm - fix interactive prompts
This commit is contained in:
parent
8a14cfb590
commit
b94ebaa4bd
@ -266,11 +266,11 @@ impl Action {
|
|||||||
.and_then(|fd| fd.metadata())
|
.and_then(|fd| fd.metadata())
|
||||||
.and_then(|meta| Ok(Filetype::from(meta)))?
|
.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 mut reply = String::new();
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
let _read = stdin.read_line(&mut reply);
|
let _read = stdin.read_line(&mut reply);
|
||||||
match reply.as_str() {
|
match reply.trim_end() {
|
||||||
"y" | "Y" | "yes" | "Yes" => Ok(Some(ft)),
|
"y" | "Y" | "yes" | "Yes" => Ok(Some(ft)),
|
||||||
_ => Ok(None),
|
_ => Ok(None),
|
||||||
}
|
}
|
||||||
@ -317,14 +317,16 @@ impl AllActions {
|
|||||||
fn prompt(&self) -> bool {
|
fn prompt(&self) -> bool {
|
||||||
let len = self.items.len();
|
let len = self.items.len();
|
||||||
if len > 3 {
|
if len > 3 {
|
||||||
print!("rm: remove {len} arguments? ");
|
eprint!("rm: remove {len} arguments? ");
|
||||||
}
|
let mut reply = String::new();
|
||||||
let mut reply = String::new();
|
let stdin = io::stdin();
|
||||||
let stdin = io::stdin();
|
let _read = stdin.read_line(&mut reply);
|
||||||
let _read = stdin.read_line(&mut reply);
|
match reply.as_str() {
|
||||||
match reply.as_str() {
|
"y" | "Y" | "yes" | "Yes" => true,
|
||||||
"y" | "Y" | "yes" | "Yes" => true,
|
_ => false,
|
||||||
_ => false,
|
}
|
||||||
|
} else {
|
||||||
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user