From 2e61580b9966a1fdff7798435b76cdbbe64cac03 Mon Sep 17 00:00:00 2001 From: Pat Laster Date: Mon, 17 Oct 2022 17:40:33 -0500 Subject: [PATCH] Cleaner force_prompt_never --- src/uu/rm/src/rm.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 93f99eea3..b8362adfc 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -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 {