From b93bae2964ce52ad24dbd16ee110593096efb944 Mon Sep 17 00:00:00 2001 From: John Shin Date: Tue, 30 May 2023 13:34:00 -0700 Subject: [PATCH] tail: fix parsing logic and add quote --- src/uu/tail/src/args.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/uu/tail/src/args.rs b/src/uu/tail/src/args.rs index 5fb5ef2b3..955a9d8f6 100644 --- a/src/uu/tail/src/args.rs +++ b/src/uu/tail/src/args.rs @@ -80,7 +80,7 @@ impl FilterMode { Err(e) => { return Err(USimpleError::new( 1, - format!("invalid number of bytes: {e}"), + format!("invalid number of bytes: '{e}'"), )) } } @@ -415,16 +415,17 @@ fn parse_num(src: &str) -> Result { starting_with = true; } } - } else { - return Err(ParseSizeError::ParseFailure(src.to_string())); } - parse_size(size_string).map(|n| match (n, starting_with) { - (0, true) => Signum::PlusZero, - (0, false) => Signum::MinusZero, - (n, true) => Signum::Positive(n), - (n, false) => Signum::Negative(n), - }) + match parse_size(size_string) { + Ok(n) => match (n, starting_with) { + (0, true) => Ok(Signum::PlusZero), + (0, false) => Ok(Signum::MinusZero), + (n, true) => Ok(Signum::Positive(n)), + (n, false) => Ok(Signum::Negative(n)), + }, + Err(_) => Err(ParseSizeError::ParseFailure(size_string.to_string())), + } } pub fn parse_args(args: impl uucore::Args) -> UResult {