diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index f3884f302..a9c9597bb 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1091,13 +1091,13 @@ impl Config { Dereference::DirArgs }; - let tab_size = if !needs_color { + let tab_size = if needs_color { + Some(0) + } else { options .get_one::(options::format::TAB_SIZE) .and_then(|size| size.parse::().ok()) .or_else(|| std::env::var("TABSIZE").ok().and_then(|s| s.parse().ok())) - } else { - Some(0) } .unwrap_or(SPACES_IN_TAB); diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 856183a54..4d460d715 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -736,16 +736,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .flatten() .cloned(); - if !config.gnu_ext { - input_files = vec![files.next().unwrap_or("-".to_string())]; - output_file = files.next().unwrap_or("-".to_string()); - if let Some(file) = files.next() { - return Err(UUsageError::new( - 1, - format!("extra operand {}", file.quote()), - )); - } - } else { + if config.gnu_ext { input_files = { let mut files = files.collect::>(); if files.is_empty() { @@ -754,6 +745,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { files }; output_file = "-".to_string(); + } else { + input_files = vec![files.next().unwrap_or("-".to_string())]; + output_file = files.next().unwrap_or("-".to_string()); + if let Some(file) = files.next() { + return Err(UUsageError::new( + 1, + format!("extra operand {}", file.quote()), + )); + } } let word_filter = WordFilter::new(&matches, &config)?; diff --git a/src/uucore/src/lib/features/format/num_format.rs b/src/uucore/src/lib/features/format/num_format.rs index 52065c8b1..ea635230e 100644 --- a/src/uucore/src/lib/features/format/num_format.rs +++ b/src/uucore/src/lib/features/format/num_format.rs @@ -328,14 +328,14 @@ impl Formatter<&ExtendedBigDecimal> for Float { } fn get_sign_indicator(sign: PositiveSign, negative: bool) -> String { - if !negative { + if negative { + String::from("-") + } else { match sign { PositiveSign::None => String::new(), PositiveSign::Plus => String::from("+"), PositiveSign::Space => String::from(" "), } - } else { - String::from("-") } } diff --git a/src/uucore/src/lib/features/parser/num_parser.rs b/src/uucore/src/lib/features/parser/num_parser.rs index 894982c75..30d7760a9 100644 --- a/src/uucore/src/lib/features/parser/num_parser.rs +++ b/src/uucore/src/lib/features/parser/num_parser.rs @@ -638,13 +638,13 @@ pub(crate) fn parse<'a>( // Return what has been parsed so far. If there are extra characters, mark the // parsing as a partial match. - if !rest.is_empty() { + if rest.is_empty() { + ebd_result + } else { Err(ExtendedParserError::PartialMatch( ebd_result.unwrap_or_else(|e| e.extract()), rest, )) - } else { - ebd_result } }