From 163c728ceaaac88dbb3b0bc04b1092e137cdf0fd Mon Sep 17 00:00:00 2001 From: Rob Muhlestein Date: Tue, 8 Nov 2022 15:36:44 -0500 Subject: [PATCH] Send all ExitError output through PrintMark --- z/bonzai.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/z/bonzai.go b/z/bonzai.go index df9e0c8..ad10cc6 100644 --- a/z/bonzai.go +++ b/z/bonzai.go @@ -245,22 +245,34 @@ func Exit() { // has been set to true. Commands should usually never call ExitError // themselves returning an error from their Method instead. func ExitError(err ...interface{}) { + prev := os.Stdout + os.Stdout = os.Stderr + previ := IndentBy + IndentBy = 0 + switch e := err[0].(type) { + case string: if len(e) > 1 { - log.Printf(e+"\n", err[1:]...) + PrintMarkf(e+"\n", err[1:]...) } else { - log.Println(e) + PrintMark(e) } + case error: out := fmt.Sprintf("%v", e) if len(out) > 0 { - log.Println(out) + PrintMark(out) } } + + IndentBy = previ + os.Stdout = prev + if !DoNotExit { os.Exit(1) } + } // ArgsFrom returns a list of field strings split on space with an extra