From: Philippe Proulx Date: Wed, 14 Jun 2017 02:42:58 +0000 (-0400) Subject: Use BABELTRACE_FORCE_COLORS environment variable to force color support X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=62128320f132f643c5d43fce0220531143614180;p=babeltrace.git Use BABELTRACE_FORCE_COLORS environment variable to force color support This allows this use case: BABELTRACE_FORCE_COLORS=1 babeltrace ... |& less -R to see the logging's color in `less`. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/common/common.c b/common/common.c index 609975f7..96532e2b 100644 --- a/common/common.c +++ b/common/common.c @@ -240,6 +240,7 @@ bool bt_common_colors_supported(void) static bool supports_colors = false; static bool supports_colors_set = false; const char *term; + const char *force; if (supports_colors_set) { goto end; @@ -247,6 +248,12 @@ bool bt_common_colors_supported(void) supports_colors_set = true; + force = getenv("BABELTRACE_FORCE_COLORS"); + if (force && strcmp(force, "1") == 0) { + supports_colors = true; + goto end; + } + term = getenv("TERM"); if (!term) { goto end;