Add honor the NO_COLOR env var
This commit is contained in:
parent
f88bf68578
commit
5786c01c8c
1 changed files with 9 additions and 3 deletions
|
@ -228,13 +228,19 @@ int term_has_color(void *ctx)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return _term_has_color(ctx);
|
return _term_has_color(ctx);
|
||||||
#else
|
#else
|
||||||
char const *env = getenv("RTL433_COLOR");
|
char const *color = getenv("RTL433_COLOR");
|
||||||
if (env && strcmp(env, "always") == 0) {
|
if (color && strcmp(color, "always") == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (env && strcmp(env, "never") == 0) {
|
if (color && strcmp(color, "never") == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char const *no_color = getenv("NO_COLOR");
|
||||||
|
if (no_color && no_color[0] != '\0') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
FILE *fp = (FILE *)ctx;
|
FILE *fp = (FILE *)ctx;
|
||||||
return isatty(fileno(fp));
|
return isatty(fileno(fp));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue