Quellcode durchsuchen

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.
Daniel Hiltgen vor 6 Monaten
Ursprung
Commit
35ec7f079f
1 geänderte Dateien mit 1 neuen und 1 gelöschten Zeilen
  1. 1 1
      cmd/cmd.go

+ 1 - 1
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
 	}