internal/debug: support cygwin/msys2 using isatty

This commit is contained in:
hackyminer 2018-09-22 00:26:36 +09:00
parent 3d15a8663c
commit f92567cfb4
No known key found for this signature in database
GPG key ID: 46D453DDCA4B766F

View file

@ -25,11 +25,11 @@ import (
"runtime" "runtime"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log/term"
"github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/exp" "github.com/ethereum/go-ethereum/metrics/exp"
"github.com/fjl/memsize/memsizeui" "github.com/fjl/memsize/memsizeui"
colorable "github.com/mattn/go-colorable" colorable "github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"gopkg.in/urfave/cli.v1" "gopkg.in/urfave/cli.v1"
) )
@ -101,7 +101,7 @@ var (
) )
func init() { func init() {
usecolor := term.IsTty(os.Stderr.Fd()) && os.Getenv("TERM") != "dumb" usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
output := io.Writer(os.Stderr) output := io.Writer(os.Stderr)
if usecolor { if usecolor {
output = colorable.NewColorableStderr() output = colorable.NewColorableStderr()