GithubHelp home page GithubHelp logo

why help exits with 1? about kubectx HOT 8 CLOSED

ahmetb avatar ahmetb commented on May 15, 2024
why help exits with 1?

from kubectx.

Comments (8)

ahmetb avatar ahmetb commented on May 15, 2024

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?

from kubectx.

tivvit avatar tivvit commented on May 15, 2024

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 👍

from kubectx.

ahmetb avatar ahmetb commented on May 15, 2024

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.

from kubectx.

tivvit avatar tivvit commented on May 15, 2024

from kubectx.

ahmetb avatar ahmetb commented on May 15, 2024

Yes.

from kubectx.

tivvit avatar tivvit commented on May 15, 2024

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

from kubectx.

ahmetb avatar ahmetb commented on May 15, 2024

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

from kubectx.

tivvit avatar tivvit commented on May 15, 2024

thanks :)

from kubectx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.