Skip to content
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

Use precise exit code on usage error #1327

Closed
killercup opened this issue Aug 3, 2018 · 1 comment
Closed

Use precise exit code on usage error #1327

killercup opened this issue Aug 3, 2018 · 1 comment

Comments

@killercup
Copy link
Contributor

Most people exit their program status code 1 on an error. To differentiate between program errors, the BSD folks made a guideline with exit codes (>1) to be more specific. For example, if the user doesn't have the necessary permissions, you should exit with 77.

I'm not trying to advocate rigorously following this. I want to argue from a different perspective: If people tend to use 1 for generic errors, clap should probably not use 1, so if people want to detect usage errors, they have a chance to do so. Thus, I propose changing the exit code to 64 (or exitcode::USAGE).

It seems that only these places need to be touched:

process::exit(1);

process::exit(1);

As one might see this as a breaking change for consumers, it need to land before the 3.0 release.

danielthegray added a commit to danielthegray/clap that referenced this issue Jan 17, 2020
The reason to do this is described well in issue clap-rs#1327. It is also a
recommendation of the Rust book itself:
https://rust-cli.github.io/book/in-depth/exit-code.html
danielthegray added a commit to danielthegray/clap that referenced this issue Jan 17, 2020
The reason to do this is described well in issue clap-rs#1327. It is also a
recommendation of the Rust book itself:
https://rust-cli.github.io/book/in-depth/exit-code.html
pksunkara added a commit that referenced this issue Jan 30, 2020
imp: Add exitcode::USAGE exit code as suggested in #1327
@pksunkara
Copy link
Member

Merged the relevant PR.

bors bot added a commit that referenced this issue Feb 3, 2020
1653: Revert " imp: Add exitcode::USAGE exit code as suggested in #1327" r=pksunkara a=Dylan-DPC

Reverts #1637

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
bors bot added a commit that referenced this issue Feb 3, 2020
1653: Revert " imp: Add exitcode::USAGE exit code as suggested in #1327" r=me a=Dylan-DPC

Reverts #1637

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
@tertsdiepraam tertsdiepraam mentioned this issue Feb 9, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants