From 8c9b0befa5ab97eb81ce7f80c80aa66b89245283 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Tue, 30 Apr 2024 20:18:54 -0500 Subject: [PATCH] fix: Ensure exit status is set by recover func --- main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.go b/main.go index 21009515..a6563cc3 100644 --- a/main.go +++ b/main.go @@ -17,11 +17,14 @@ var errPanic = errors.New("panic") func main() { defer func() { var err error + var status int if msg := recover(); msg != nil { + status = 1 err = fmt.Errorf("%w: %v\n\n%s", errPanic, msg, string(debug.Stack())) _, _ = io.WriteString(os.Stderr, err.Error()) } util.PostRun(err) + os.Exit(status) }() rootCmd := cmd.NewCommand()