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

why help exits with 1? #69

Closed
tivvit opened this issue Aug 11, 2018 · 8 comments · Fixed by #72
Closed

why help exits with 1? #69

tivvit opened this issue Aug 11, 2018 · 8 comments · Fixed by #72

Comments

@tivvit
Copy link
Contributor

tivvit commented Aug 11, 2018

https://github.com/ahmetb/kubectx/blob/master/kubectx#L40

@ahmetb
Copy link
Owner

ahmetb commented Aug 11, 2018

There’s often no consensus on whether —help should exit with error in gnu tools and similar tools like curl, git etc. This is fine since the flag is meant to be used interactively and therefore prints to stderr, which is another indicator of it is not meant the help output should be used by the programs. 😊

If you try many tools, you’ll see some exit successfully on help and some won’t.

My question would be more like what difference does this make for you in terms of kubectx context? Do you need to exit this with success status?

@tivvit
Copy link
Contributor Author

tivvit commented Aug 12, 2018

git --help and curl -h both returned 0 status on my system. To be fair I thought it is very common to return 0 staus for help. At least I thought exit status 1 is for erroneous states.

But I get your point some tools may exit with status 1 for help.

I am developing a tool for installing and keeping useful scripts up to date. It is based on https://github.com/slackhq/magic-cli but purely in bash and the installation is based on Make. Part of the installation is generating help which failed on exit status 1. It was simple to solve (kubectx -h || true) but I was just surprised. I do not consider myself a bash guru so I asked ;)
The tool I am writing will be hopefully open-sourced soon.

I think there is no solution to this issue, therefore you can close it.

BTW thanks for the great tools 👍

@ahmetb
Copy link
Owner

ahmetb commented Aug 13, 2018

I think this can be fixed easily and I'm ok with fixing it for --help.

It can also be used in brew formula as a test, which does a nastier test today: https://github.com/Homebrew/homebrew-core/blob/a21926ac32853a1e64fdf23c74cec2d9e98cb0a8/Formula/kubectx.rb#L26-L29

Updating the exit code for --help would likely break this installation script, as it expects to see (1) exit code 1 (2) "USAGE:" in --help stderr output. So we just need to tag a release and update brew formula with this.

Are you interested in fixing this in kubectx? We probably need to just move exit out of usage function.

@tivvit
Copy link
Contributor Author

tivvit commented Aug 13, 2018 via email

@ahmetb
Copy link
Owner

ahmetb commented Aug 13, 2018

Yes.

@tivvit
Copy link
Contributor Author

tivvit commented Aug 19, 2018

prepared PR to homebrew too Homebrew/homebrew-core#31288

@ahmetb
Copy link
Owner

ahmetb commented Aug 20, 2018

We still haven't tagged a release yet, I'll ping you when we're ready to tag another release.

@tivvit
Copy link
Contributor Author

tivvit commented Aug 20, 2018

thanks :)

ahmetb added a commit that referenced this issue Aug 23, 2018
- FEATURE: interactive search mode when kubectx and kubens are ran without any
  arguments and fzf(1) is detected in PATH. (#71, #74)
- FIX: kubectx -d now doesn't ignore arguments after the first argument. (#75)
- FIX: empty output bug when TERM=vt100 even though NO_COLOR is set. (#57, #73)
- FIX: --help exits with code 0 now. (#69, #72)
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.

2 participants