mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-04 20:51:44 +00:00
Disable ANSI emulation in certain windows shells
This disables recently added ANSI emulation feature in certain Windows shells (like ConEmu) where ANSI output is emulated by default with builtin functionality in the shell. MSYS (mingw) runs in cmd.exe window and it doesn't support emulation. Cygwin doesn't even pass terminal handles to docker.exe as far as I can tell, stdin/stdout/stderr handles are behaving like non-TTY. Therefore not even including that in the check. Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com> Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <hugs@docker.com> (github: jfrazelle) Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <jess@docker.com> (github: jfrazelle)
This commit is contained in:
committed by
Jessica Frazelle
parent
03b36f3451
commit
208178c799
@@ -3,6 +3,7 @@ package term
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/docker/docker/pkg/term/winconsole"
|
||||
)
|
||||
@@ -114,5 +115,23 @@ func GetFdInfo(in interface{}) (uintptr, bool) {
|
||||
}
|
||||
|
||||
func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||
return winconsole.StdStreams()
|
||||
var shouldEmulateANSI bool
|
||||
switch {
|
||||
case os.Getenv("ConEmuANSI") == "ON":
|
||||
// ConEmu shell, ansi emulated by default and ConEmu does an extensively
|
||||
// good emulation.
|
||||
shouldEmulateANSI = false
|
||||
case os.Getenv("MSYSTEM") != "":
|
||||
// MSYS (mingw) cannot fully emulate well and still shows escape characters
|
||||
// mostly because it's still running on cmd.exe window.
|
||||
shouldEmulateANSI = true
|
||||
default:
|
||||
shouldEmulateANSI = true
|
||||
}
|
||||
|
||||
if shouldEmulateANSI {
|
||||
return winconsole.StdStreams()
|
||||
}
|
||||
|
||||
return os.Stdin, os.Stdout, os.Stderr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user