Don't generate colorized output escapes when stderr isn't a TTY.
When piping to a pile, more/less, etc, this is generally undesirable. This behavior can be overridden with the --colorized-output command-line flag.
This commit is contained in:
5
util.cpp
5
util.cpp
@@ -44,6 +44,7 @@
|
||||
#endif
|
||||
#else
|
||||
#include <alloca.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -94,6 +95,10 @@ static bool
|
||||
lHaveANSIColors() {
|
||||
static bool r = (getenv("TERM") != NULL &&
|
||||
strcmp(getenv("TERM"), "dumb") != 0);
|
||||
#ifndef ISPC_IS_WINDOWS
|
||||
r &= isatty(2);
|
||||
#endif // !ISPC_IS_WINDOWS
|
||||
r |= g->forceColoredOutput;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user