1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-05 15:37:47 +00:00

Cleaner force_prompt_never

This commit is contained in:
Pat Laster 2022-10-17 17:40:33 -05:00
parent 03578a7aca
commit 2e61580b99

View file

@ -89,17 +89,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// If -f(--force) is before any -i (or variants) we want prompts else no prompts
let force_prompt_never: bool = force_flag && {
if matches.value_source(OPT_FORCE) == Some(ValueSource::CommandLine) {
let force_index = matches.index_of(OPT_FORCE).unwrap_or(0);
![OPT_PROMPT, OPT_PROMPT_MORE, OPT_INTERACTIVE]
.iter()
.any(|flag| {
matches.value_source(flag) == Some(ValueSource::CommandLine)
&& matches.index_of(flag).unwrap_or(0) > force_index
})
} else {
false
}
let force_index = matches.index_of(OPT_FORCE).unwrap_or(0);
![OPT_PROMPT, OPT_PROMPT_MORE, OPT_INTERACTIVE]
.iter()
.any(|flag| {
matches.value_source(flag) == Some(ValueSource::CommandLine)
&& matches.index_of(flag).unwrap_or(0) > force_index
})
};
if files.is_empty() && !force_flag {