Fix stdin-is-a-terminal check for Windows

This commit is contained in:
John Kerl 2021-04-07 21:12:09 -04:00
parent fe204e9fa3
commit 493ae2aa30

View file

@ -20,12 +20,10 @@ const DEFAULT_PRIMARY_PROMPT = "[mlr] "
const DEFAULT_SECONDARY_PROMPT = ""
func getInputIsTerminal() bool {
if runtime.GOOS == "windows" {
if runtime.GOOS == "windows" && os.Getenv("MSYSTEM") != "" {
// Sadly, term.IsTerminal doesn't work inside MSYS2 but does work
// outside MSYS2. Also sadly, I don't know how to tell the difference
// programatically between inside/outside MSYS2 here. So, as a
// workaround, I am simply defaulting to "is a terminal" here. Issues
// with regression-testing will need to be dealt with later.
// outside MSYS2. So in that case we simply return true so that the mlr
// repl has a prompt.
return true
} else {
return term.IsTerminal(int(os.Stdin.Fd()))