From 62128320f132f643c5d43fce0220531143614180 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 13 Jun 2017 22:42:58 -0400 Subject: [PATCH] Use BABELTRACE_FORCE_COLORS environment variable to force color support MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- common/common.c | 7 +++++++ 1 file changed, 7 insertions(+) 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; -- 2.34.1