From 35ec7f079ff3d08b1b837bffe202107abaa00555 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Fri, 25 Oct 2024 13:43:16 -0700 Subject: [PATCH] Fix unicode output on windows with redirect to file (#7358) If we're not writing out to a terminal, avoid setting the console mode on windows, which corrupts the output file. --- cmd/cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index a44ed5c6..b8c9c640 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1318,7 +1318,7 @@ func NewCLI() *cobra.Command { log.SetFlags(log.LstdFlags | log.Lshortfile) cobra.EnableCommandSorting = false - if runtime.GOOS == "windows" { + if runtime.GOOS == "windows" && term.IsTerminal(int(os.Stdout.Fd())) { console.ConsoleFromFile(os.Stdin) //nolint:errcheck }