Closed
Description
When the -help
or -h
flags are undefined and invoked, the flag
package handles this situation as a special case and prints a nice and helpful default help text, but exit the process with exit code 2. This proposal proposes the exit code be 0 by default and configurable for this specific case.
Emphasis: this proposal does not propose/incur any changes to programs which has -h
or -help
defined.
As a concrete example, using gofmt
, which uses the flag
package and does not have -help
or -h
defined, the behavior today is:
$ gofmt -help
usage: gofmt [flags] [path ...]
-cpuprofile string
write cpu profile to this file
<...abbreviated...>
$ echo $?
2
The proposed behavior is:
$ gofmt -help
usage: gofmt [flags] [path ...]
-cpuprofile string
write cpu profile to this file
<...abbreviated...>
$ echo $?
0