Default to no colors if output is not terminal.

This commit is contained in:
wb2osz 2019-09-30 22:04:49 -04:00
parent 10ad90b3db
commit 3765f26554
1 changed files with 6 additions and 0 deletions

View File

@ -59,6 +59,8 @@
#endif #endif
#if __WIN32__ #if __WIN32__
#include <stdio.h>
#include <io.h>
#else #else
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -252,7 +254,11 @@ int main (int argc, char *argv[])
* something else such as "tee") but command line can override this. * something else such as "tee") but command line can override this.
*/ */
#if __WIN32__
t_opt = _isatty(_fileno(stdout)) > 0;
#else
t_opt = isatty(fileno(stdout)); t_opt = isatty(fileno(stdout));
#endif
/* 1 = normal, 0 = no text colors. */ /* 1 = normal, 0 = no text colors. */
/* 2, 3, ... alternate escape sequences for different terminals. */ /* 2, 3, ... alternate escape sequences for different terminals. */