summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2011-10-18 18:25:39 -0700
committerCarl Worth <cworth@cworth.org>2011-10-19 09:54:30 -0700
commit71f2de7f059df2587b2ba4489aa1cc399f3ebdb8 (patch)
tree4d4fc85edffb817245a66ec73eab1fad7dfbe14d
parent06e85193037ea678ddfb78e23fe65a13516448e0 (diff)
tracedump: Don't use color when stdout is not a tty
Previously, if one did an operation like: tracedump file.trace > file.dump The resulting file would be cluttered with escape sequences intending to change color. Rather than requiring the user to find the --no-color option, we can simply not use any color escape sequences when stdout is not a tty.
-rw-r--r--tracedump.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/tracedump.cpp b/tracedump.cpp
index c210a0c..77d779d 100644
--- a/tracedump.cpp
+++ b/tracedump.cpp
@@ -34,9 +34,6 @@
#include "trace_parser.hpp"
-static bool color = true;
-
-
static void usage(void) {
std::cout <<
"Usage: tracedump [OPTION] [TRACE...]\n"
@@ -51,6 +48,7 @@ static void usage(void) {
int main(int argc, char **argv)
{
int i;
+ bool color = isatty(1);
for (i = 1; i < argc; ++i) {
const char *arg = argv[i];