From fa3e43f3092b3144be2911dfc23dc69bfbf85bc3 Mon Sep 17 00:00:00 2001 From: "Daniel M. Weeks" Date: Tue, 26 Jan 2016 11:37:13 -0500 Subject: [PATCH] Do not use color unless output is a tty --- textcolor.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/textcolor.c b/textcolor.c index 6b1c421..07eaaf9 100644 --- a/textcolor.c +++ b/textcolor.c @@ -77,6 +77,7 @@ #include #include #include +#include #if __WIN32__ @@ -207,7 +208,7 @@ void text_color_init (int enable_color) g_enable_color = enable_color; - if (g_enable_color == 0) { + if (g_enable_color == 0 || isatty(fileno(stdout)) == 0) { return; } #if __WIN32__ @@ -250,7 +251,7 @@ void text_color_set ( enum dw_color_e c ) WORD attr; HANDLE h; - if (g_enable_color == 0) { + if (g_enable_color == 0 || isatty(fileno(stdout)) == 0) { return; } @@ -294,7 +295,7 @@ void text_color_set ( enum dw_color_e c ) void text_color_set ( enum dw_color_e c ) { - if (g_enable_color == 0) { + if (g_enable_color == 0 || isatty(fileno(stdout)) == 0) { return; }