"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: standardize exit status across all usage functions
To:
Johannes Thyssen Tishman <johannes@thyssentishman.com>, gameoftrees@openbsd.org
Date:
Wed, 19 Nov 2025 12:34:28 +0100

Download raw body.

Thread
On Wed, Nov 19, 2025 at 10:10:50AM +0000, Johannes Thyssen Tishman wrote:
> As discussed on IRC, I noticed that most GoT command-line tools exit
> with status 1 and print to stderr when using the '-h' flag to print the
> usage string of a command, e.g., got -h log. This is not consistent with
> the behavior of using the '-h' flag without a command, e.g., got -h,
> which exits with status 0 and prints to stdout. To me the latter is the
> correct behavior, as it follows the user request and therefore should
> exit with "success". This commit standardizes this behavior across
> all[1] usage functions. The following exemplifies this change:
> 
> Without this commit:
> 
> command             prints to  exit status
> ------------------------------------------
> got -h              stdout               0
> got -h valid-cmd    stderr               1
> got -h invalid-cmd  stderr               1
> 
> With this commit:
> 
> command             prints to  exit status
> ------------------------------------------
> got -h              stdout               0
> got -h valid-cmd    stdout               0
> got -h invalid-cmd  stderr               1
> 
> Of course, if preferred, we could also do the opposite and make using
> the '-h' flag without a command exit with status 1 and print to stderr.
> This would yield a much smaller diff.

Let's not throw away all of the work you've already done :)

And I agree that regular use of -h should not result in an error code.

> The test suite is passing, but I didn't run the tests for gotd, gotwebd
> and gotsys as I currently don't have a spare machine to set up the
> required environment and don't want to do it on my personal machine. I'd
> appreciate if someone could check this.

All tests are still passing for me with your changes.  ok by me.