-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
truncate: change cli error return code #3012
Conversation
Exit with status code 1 for argument parsing errors in `truncate`. When `clap` encounters an error during argument parsing, it exits with status code 2. This causes some GNU tests to fail since they expect status code 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good! Could you add a small test for this behaviour? Just testing that truncate --this-arg-does-not-exist
returns 1
is fine.
src/uu/truncate/src/truncate.rs
Outdated
e.print().expect("Error writing clap::Error"); | ||
match e.kind { | ||
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => { | ||
std::process::exit(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit to make it a bit cleaner using UResult
and so that we don't have to call std::process:exit
:
.map_err(|e| {
e.print().expect("Error writing clap::Error");
match e.kind {
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => 0,
_ => 1,
}
})?;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it. Working on it now.
Exit with status code 1 for argument parsing errors in
truncate
. Whenclap
encounters an error during argument parsing, it exits with status code 2. This causes some GNU tests to fail since they expect status code 1.Closes #2951