From 8a69aa54fbca7245fca1e8bb83b3bfb1ca73796b Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 27 Sep 2022 16:34:34 +0200 Subject: [PATCH] color_out_init: check if the output is terminal In Windows, if output is not MSYS, check if output is a terminal and do not relay on setWinTermAnsiColors() returning true. + check for MSYS terminal first (avoids attempt to set ansi color on MSYS terminal) refers to #256 --- src/utils/color_out.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/color_out.cpp b/src/utils/color_out.cpp index 522efe975..b79cef1e0 100644 --- a/src/utils/color_out.cpp +++ b/src/utils/color_out.cpp @@ -135,7 +135,7 @@ bool color_output_init() { return false; } #ifdef _WIN32 - color_stdout = setWinTermAnsiColors(STD_OUTPUT_HANDLE) || isMsysPty(fileno(stdout)); + color_stdout = isMsysPty(fileno(stdout)) || (_isatty(fileno(stdout)) && setWinTermAnsiColors(STD_OUTPUT_HANDLE)); #else color_stdout = isatty(fileno(stdout)); #endif