mirror of
https://github.com/nushell/nushell.git
synced 2025-04-01 03:36:53 +02:00
fix operating more than 2 file at the same time
This commit is contained in:
parent
8c2ae1eed1
commit
b3192ddc97
@ -74,7 +74,7 @@ impl Command for Cp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if interactive && !force {
|
if interactive && !force {
|
||||||
let mut remove_index: Vec<usize> = vec![];
|
let mut remove: Vec<usize> = vec![];
|
||||||
for (index, file) in sources.iter().enumerate() {
|
for (index, file) in sources.iter().enumerate() {
|
||||||
let prompt = format!(
|
let prompt = format!(
|
||||||
"Are you shure that you want to copy {} to {}?",
|
"Are you shure that you want to copy {} to {}?",
|
||||||
@ -90,10 +90,13 @@ impl Command for Cp {
|
|||||||
let input = get_confirmation(prompt)?;
|
let input = get_confirmation(prompt)?;
|
||||||
|
|
||||||
if !input {
|
if !input {
|
||||||
remove_index.push(index);
|
remove.push(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for index in remove_index {
|
|
||||||
|
remove.reverse();
|
||||||
|
|
||||||
|
for index in remove {
|
||||||
sources.remove(index);
|
sources.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ impl Command for Mv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if interactive && !force {
|
if interactive && !force {
|
||||||
let mut remove_index: Vec<usize> = vec![];
|
let mut remove: Vec<usize> = vec![];
|
||||||
for (index, file) in sources.iter().enumerate() {
|
for (index, file) in sources.iter().enumerate() {
|
||||||
let prompt = format!(
|
let prompt = format!(
|
||||||
"Are you shure that you want to move {} to {}?",
|
"Are you shure that you want to move {} to {}?",
|
||||||
@ -76,10 +76,13 @@ impl Command for Mv {
|
|||||||
let input = get_confirmation(prompt)?;
|
let input = get_confirmation(prompt)?;
|
||||||
|
|
||||||
if !input {
|
if !input {
|
||||||
remove_index.push(index);
|
remove.push(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for index in remove_index {
|
|
||||||
|
remove.reverse();
|
||||||
|
|
||||||
|
for index in remove {
|
||||||
sources.remove(index);
|
sources.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ fn rm(context: &EvaluationContext, call: &Call) -> Result<Value, ShellError> {
|
|||||||
let force = call.has_flag("force");
|
let force = call.has_flag("force");
|
||||||
|
|
||||||
if interactive && !force {
|
if interactive && !force {
|
||||||
let mut remove_index: Vec<usize> = vec![];
|
let mut remove: Vec<usize> = vec![];
|
||||||
for (index, file) in targets.iter().enumerate() {
|
for (index, file) in targets.iter().enumerate() {
|
||||||
let prompt: String = format!(
|
let prompt: String = format!(
|
||||||
"Are you sure that you what to delete {}?",
|
"Are you sure that you what to delete {}?",
|
||||||
@ -137,11 +137,13 @@ fn rm(context: &EvaluationContext, call: &Call) -> Result<Value, ShellError> {
|
|||||||
let input = get_confirmation(prompt)?;
|
let input = get_confirmation(prompt)?;
|
||||||
|
|
||||||
if !input {
|
if !input {
|
||||||
remove_index.push(index);
|
remove.push(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for index in remove_index {
|
remove.reverse();
|
||||||
|
|
||||||
|
for index in remove {
|
||||||
targets.remove(index);
|
targets.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user