turn-off coloring if we have std{err,out} dumb terminals (#19667)

This commit is contained in:
Harshavardhana
2024-05-03 17:17:57 -07:00
committed by GitHub
parent da3e7747ca
commit 8ff70ea5a9
3 changed files with 10 additions and 1 deletions

View File

@@ -63,6 +63,7 @@ import (
"github.com/minio/pkg/v2/ellipses"
"github.com/minio/pkg/v2/env"
xnet "github.com/minio/pkg/v2/net"
"golang.org/x/term"
)
// serverDebugLog will enable debug printing
@@ -73,6 +74,13 @@ var (
)
func init() {
if !term.IsTerminal(int(os.Stdout.Fd())) || !term.IsTerminal(int(os.Stderr.Fd())) {
color.TurnOff()
}
if env.Get("NO_COLOR", "") != "" || env.Get("TERM", "") == "dumb" {
color.TurnOff()
}
if runtime.GOOS == "windows" {
if mousetrap.StartedByExplorer() {
fmt.Printf("Don't double-click %s\n", os.Args[0])