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

wrong exit code if script returns non-zero exit code #149

Closed
powerman opened this issue Nov 3, 2024 · 0 comments · Fixed by #152
Closed

wrong exit code if script returns non-zero exit code #149

powerman opened this issue Nov 3, 2024 · 0 comments · Fixed by #152

Comments

@powerman
Copy link

powerman commented Nov 3, 2024

It looks like Usage returns exit code 0 if it was able to successfully parse args and 1 otherwise. There are two issues here:

  1. It silently convert failed scripts to successful.
  2. It overwrite script exit code 1 with own meaning.

I propose to use some rarely used exit code for arg parsing issues and return script's actual exit code as is (probably makes sense to do the same as other common tools running other tools do - e.g. nice).

$ usage --version
usage-cli 1.0.1
$ cat >fail <<'EOF'
#!/usr/bin/env -S usage bash
#USAGE about "This script fails"
echo Oops                       
exit 1   
EOF
$ chmod +x fail
$ ./fail; echo $?
Oops
0
$ bash ./fail; echo $?
Oops
1
$ usage bash ./fail; echo $?
Oops
0
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 a pull request may close this issue.

1 participant