From 54b6cca78e5a5193d358055b8d6585d6b2307d09 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 20 Jan 2016 14:51:55 -0700 Subject: [PATCH] Remove panic from help. There is a panic in printHelp that can be trivially triggered when the shell closes os.Stdout. This happens, for example, when data is piped between a cli app and something else. See https://github.com/helm/helm/issues/387 --- help.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/help.go b/help.go index a246f63..ecb67c2 100644 --- a/help.go +++ b/help.go @@ -180,7 +180,9 @@ func printHelp(out io.Writer, templ string, data interface{}) { t := template.Must(template.New("help").Funcs(funcMap).Parse(templ)) err := t.Execute(w, data) if err != nil { - panic(err) + // If the writer is closed, t.Execute will fail, and there's nothing + // we can do to recover. We could send this to os.Stderr if we need. + return } w.Flush() }