8000 flag: exit 0 for default -h/-help option · Issue #37533 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
flag: exit 0 for default -h/-help option #37533
Closed
@sding3

Description

@sding3

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0