tail: fix parsing logic and add quote

This commit is contained in:
John Shin 2023-05-30 13:34:00 -07:00
parent f10faf21bc
commit b93bae2964

View file

@ -80,7 +80,7 @@ impl FilterMode {
Err(e) => { Err(e) => {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
format!("invalid number of bytes: {e}"), format!("invalid number of bytes: '{e}'"),
)) ))
} }
} }
@ -415,16 +415,17 @@ fn parse_num(src: &str) -> Result<Signum, ParseSizeError> {
starting_with = true; starting_with = true;
} }
} }
} else {
return Err(ParseSizeError::ParseFailure(src.to_string()));
} }
parse_size(size_string).map(|n| match (n, starting_with) { match parse_size(size_string) {
(0, true) => Signum::PlusZero, Ok(n) => match (n, starting_with) {
(0, false) => Signum::MinusZero, (0, true) => Ok(Signum::PlusZero),
(n, true) => Signum::Positive(n), (0, false) => Ok(Signum::MinusZero),
(n, false) => Signum::Negative(n), (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<Settings> { pub fn parse_args(args: impl uucore::Args) -> UResult<Settings> {