www
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYestin L. Harrison <yestin@ylh.io>2021-07-25 23:49:45 -0600
committerYestin L. Harrison <yestin@ylh.io>2021-07-26 00:45:50 -0600
commit75aec769c70632f4a3b2ae3d9b5b43d8dc391066 (patch)
tree0f820979b23f7a3b01c03428331f97385004c361
parent7b2b19557e3681b6af7260c5d6d68ac8354195c1 (diff)
downloadcgd-75aec769c70632f4a3b2ae3d9b5b43d8dc391066.tar.gz
cgd-75aec769c70632f4a3b2ae3d9b5b43d8dc391066.tar.xz
cgd-75aec769c70632f4a3b2ae3d9b5b43d8dc391066.zip
don't clobber default os.Exit behaviour in flag (https://pkg.go.dev/flag#CommandLine)
-rw-r--r--main.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/main.go b/main.go
index 69752f9..647e9aa 100644
--- a/main.go
+++ b/main.go
@@ -19,11 +19,15 @@ var address = flag.String("a", ":42069", "Listen address")
var envVars = flag.String("e", "", "Comma-separated list of environment variables to preserve")
func main() {
- flag.Usage = usage
+ flag.Usage = func () {
+ os.Stderr.WriteString("usage: cgd [-f] -c prog [-w wdir] [-a addr] [-e VAR1,VAR2]\n")
+ flag.PrintDefaults()
+ }
flag.Parse()
if *cmd == "" {
- usage()
+ flag.Usage()
+ os.Exit(2)
}
// This is a hack to make p9p's rc happier for some unknown reason.
@@ -63,8 +67,3 @@ func main() {
}
}
-func usage() {
- os.Stderr.WriteString("usage: cgd [-f] -c prog [-w wdir] [-a addr] [-e VAR1,VAR2]\n")
- flag.PrintDefaults()
- os.Exit(2)
-}