From 0fe84bef7286bf9b38dbb628f450ac07079f8fed Mon Sep 17 00:00:00 2001 From: "Yestin L. Harrison" Date: Fri, 2 Jul 2021 09:33:54 -0600 Subject: [PATCH] Add $NO_COLOR check to ANSI escape conditions --- src/libutil/util.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 94460b367..ee9f17228 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1374,7 +1374,9 @@ void ignoreException() bool shouldANSI() { - return isatty(STDERR_FILENO) && getEnv("TERM").value_or("dumb") != "dumb"; + return isatty(STDERR_FILENO) + && getEnv("TERM").value_or("dumb") != "dumb" + && !getEnv("NO_COLOR").has_value(); } std::string filterANSIEscapes(const std::string & s, bool filterAll, unsigned int width)