Skip to content

Conversation

hhromic
Copy link
Contributor

@hhromic hhromic commented Jun 29, 2024

The stdlib flag package (specifically ExitOnError) and most command line utilities use status code 2.
I tried to find proper sources for common exit status codes, however these are the best I could find:

From: https://stackoverflow.com/a/40484670

Exit status 0: success
Exit status 1: "failure", as defined by the program
Exit status 2: command line usage error

From: https://tldp.org/LDP/abs/html/exitcodes.html:

2 | Misuse of shell builtins (according to Bash documentation)

More importantly, currently using -1 (which translates to 255) is actually documented as a bad choice in os.Exit:

For portability, the status code should be in the range [0, 125].

Fixes #246

* The stdlib `flags` package and most command line utilities use status code `2`.
@alexflint alexflint merged commit 177b844 into alexflint:master Jun 30, 2024
@hhromic hhromic deleted the fix-246 branch June 30, 2024 14:43
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

Successfully merging this pull request may close these issues.

exit code should be 2 on flag parsing error

2 participants