summaryrefslogtreecommitdiffstats
path: root/src/line_printer.cc
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2018-11-13 14:15:43 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2018-11-13 14:15:43 (GMT)
commitbf7107bb864d0383028202e3f4a4228c02302961 (patch)
treead4ecdd3f32ab606d5d664862a400c2f3d4641ad /src/line_printer.cc
parent99c5c2287b11c8bab05fb2a8cf89dc4856c708bc (diff)
downloadNinja-bf7107bb864d0383028202e3f4a4228c02302961.zip
Ninja-bf7107bb864d0383028202e3f4a4228c02302961.tar.gz
Ninja-bf7107bb864d0383028202e3f4a4228c02302961.tar.bz2
Allow disabling of escape code stripping, fix #1475
Don't strip colors when CLICOLOR_FORCE is set to a non-zero value. This environment variable is also used by CMake's Make back-end.
Diffstat (limited to 'src/line_printer.cc')
-rw-r--r--src/line_printer.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/line_printer.cc b/src/line_printer.cc
index a3a551e..6effca6 100644
--- a/src/line_printer.cc
+++ b/src/line_printer.cc
@@ -42,6 +42,10 @@ LinePrinter::LinePrinter() : have_blank_line_(true), console_locked_(false) {
smart_terminal_ = GetConsoleScreenBufferInfo(console_, &csbi);
#endif
supports_color_ = smart_terminal_;
+ if (!supports_color_) {
+ const char* clicolor_force = getenv("CLICOLOR_FORCE");
+ supports_color_ = clicolor_force && string(clicolor_force) != "0";
+ }
}
void LinePrinter::Print(string to_print, LineType type) {