pr: exit with code 1 if --column argument is zero#11750
pr: exit with code 1 if --column argument is zero#11750sylvestre merged 12 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
|
Can we do that at same code path with |
|
@oech3 negative numbers are already handled, only numbers >= 0 could be used with |
|
Can you merge this logic to there? |
|
@oech3 That was my first plan. I would if I Could, but I can't manage to find where that check is done, close the PR if that solution isn't appropriate as I cannot propose any other fix than that. |
|
Lines 780 to 783 in 2ab8e25 parse_usize |
|
@oech3 yes, but parse_usize() is used for other purposes too, would it be safe to touch it? |
|
Maybe, this |
|
Maybe introduce a new function: fn parse_nonzero_usize(matches: &ArgMatches, opt: &str) -> Option<Result<NonZero<usize>, PrError>> |
|
@oech3, I put the exit in the match |
|
GNU testsuite comparison: |
|
What about the |
|
That -column mistake originates from the parse_usize() function |
| let option = value_to_parse.1; | ||
| i.parse().map_err(|_e| PrError::EncounteredErrors { | ||
| msg: format!("invalid {option} argument {}", i.quote()), | ||
| msg: format!("invalid -{option} argument {}", i.quote()), |
There was a problem hiding this comment.
for a future pr, please use the translate!() macro for translation
| let start_column_option = match res { | ||
| Some(Ok(0)) => { | ||
| return Err(PrError::EncounteredErrors { | ||
| msg: "invalid --column argument '0'".to_string(), |
| let column_option_value = match parse_usize(matches, options::COLUMN) { | ||
| Some(Ok(0)) => { | ||
| return Err(PrError::EncounteredErrors { | ||
| msg: "invalid --column argument '0'".to_string(), |
This pull request closes #11584 where --column shouldn't be zero.
$ cargo run pr --column=0 /etc/pacman.conf/
pr: invalid -column argument '0'