]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
safcm: don't color output if stderr is redirected
authorSimon Ruderich <simon@ruderich.org>
Sun, 9 May 2021 10:46:18 +0000 (12:46 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sun, 9 May 2021 13:18:45 +0000 (15:18 +0200)
All log messages are printed to stderr. It's confusing to still get
colored output when redirecting stderr to a file; only redirecting
stdout as well fixed this.

cmd/safcm/sync.go

index 6358f0cb60feb4570cc5dae1a9e0e24bce6a69ed..54df9ec6230efc8cffda0ff347960efb0317a61a 100644 (file)
@@ -122,7 +122,8 @@ func MainSync(args []string) error {
                return fmt.Errorf("no hosts found")
        }
 
-       isTTY := term.IsTerminal(int(os.Stdout.Fd()))
+       isTTY := term.IsTerminal(int(os.Stdout.Fd())) &&
+               term.IsTerminal(int(os.Stderr.Fd()))
 
        done := make(chan bool)
        // Collect events from all hosts and print them