mirror of
https://github.com/uutils/coreutils
synced 2025-01-19 00:24:13 +00:00
Fixed force rm
This commit is contained in:
parent
3a1098489e
commit
355136936f
1 changed files with 20 additions and 10 deletions
|
@ -91,24 +91,34 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let force_index_option = matches.index_of(OPT_FORCE);
|
let force_index_option = matches.index_of(OPT_FORCE);
|
||||||
|
|
||||||
// If -f(--force) is before any -i (or variants) we want prompts else no prompts
|
// If -f(--force) is before any -i (or variants) we want prompts else no prompts
|
||||||
let force_first: bool = {
|
let force_prompt_never: bool = {
|
||||||
if let Some(force_index) = force_index_option {
|
if let Some(force_index) = force_index_option {
|
||||||
let prompt_index_option = matches.index_of(OPT_PROMPT);
|
let prompt_index_option = matches.index_of(OPT_PROMPT);
|
||||||
let prompt_more_index_option = matches.index_of(OPT_PROMPT_MORE);
|
let prompt_more_index_option = matches.index_of(OPT_PROMPT_MORE);
|
||||||
let interactive_index_option = matches.index_of(OPT_INTERACTIVE);
|
let interactive_index_option = matches.index_of(OPT_INTERACTIVE);
|
||||||
|
|
||||||
|
let mut result = true;
|
||||||
|
|
||||||
if let Some(prompt_index) = prompt_index_option {
|
if let Some(prompt_index) = prompt_index_option {
|
||||||
prompt_index > force_index
|
if result {
|
||||||
} else if let Some(prompt_more_index_index) = prompt_more_index_option {
|
result = prompt_index <= force_index;
|
||||||
prompt_more_index_index > force_index
|
}
|
||||||
} else if let Some(interactive_index) = interactive_index_option {
|
}
|
||||||
interactive_index > force_index
|
if let Some(prompt_more_index_index) = prompt_more_index_option {
|
||||||
|
if result {
|
||||||
|
result = prompt_more_index_index <= force_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(interactive_index) = interactive_index_option {
|
||||||
|
if result {
|
||||||
|
result = interactive_index <= force_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if files.is_empty() && force_index_option.is_none() {
|
if files.is_empty() && force_index_option.is_none() {
|
||||||
|
@ -119,7 +129,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let options = Options {
|
let options = Options {
|
||||||
force: force_index_option.is_some(),
|
force: force_index_option.is_some(),
|
||||||
interactive: {
|
interactive: {
|
||||||
if force_index_option.is_some() && !force_first {
|
if force_index_option.is_some() && force_prompt_never {
|
||||||
InteractiveMode::Never
|
InteractiveMode::Never
|
||||||
} else if matches.contains_id(OPT_PROMPT) {
|
} else if matches.contains_id(OPT_PROMPT) {
|
||||||
InteractiveMode::Always
|
InteractiveMode::Always
|
||||||
|
|
Loading…
Reference in a new issue