summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-08-26 13:34:54 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-08-26 13:35:30 (GMT)
commitafd902e992b720d1b3e106bc5e425a5768872265 (patch)
tree9dddd8b57adebe8117fbd96ad89766a3f18f13f4 /googletest
parent25cc5777a17820a6339204a3552aa1dd5e428669 (diff)
downloadgoogletest-afd902e992b720d1b3e106bc5e425a5768872265.zip
googletest-afd902e992b720d1b3e106bc5e425a5768872265.tar.gz
googletest-afd902e992b720d1b3e106bc5e425a5768872265.tar.bz2
Consider all TERM values ending in "-256color" to be color supporting. In particular this handles TERM=hterm-256color correctly.
PiperOrigin-RevId: 470232889 Change-Id: Iea594a3fde2b8b0a10e527956d70ba0bb3452e08
Diffstat (limited to 'googletest')
-rw-r--r--googletest/src/gtest.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 513a887..81409a3 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3245,18 +3245,15 @@ bool ShouldUseColor(bool stdout_is_tty) {
#else
// On non-Windows platforms, we rely on the TERM variable.
const char* const term = posix::GetEnv("TERM");
- const bool term_supports_color =
+ const bool term_supports_color = term != nullptr && (
String::CStringEquals(term, "xterm") ||
String::CStringEquals(term, "xterm-color") ||
- String::CStringEquals(term, "xterm-256color") ||
String::CStringEquals(term, "screen") ||
- String::CStringEquals(term, "screen-256color") ||
String::CStringEquals(term, "tmux") ||
- String::CStringEquals(term, "tmux-256color") ||
String::CStringEquals(term, "rxvt-unicode") ||
- String::CStringEquals(term, "rxvt-unicode-256color") ||
String::CStringEquals(term, "linux") ||
- String::CStringEquals(term, "cygwin");
+ String::CStringEquals(term, "cygwin") ||
+ String::EndsWithCaseInsensitive(term, "-256color"));
return stdout_is_tty && term_supports_color;
#endif // GTEST_OS_WINDOWS
}