From 4ebfd53de03599b73838ee339e47652ac26c37c0 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 15 Sep 2023 17:24:26 -0600 Subject: Support the NO_COLOR environment variable I ran across this site: https://no-color.org/ ... which lobbies for tools to recognize the NO_COLOR environment variable and disable any terminal styling when it is seen. This patch implements this for gdb. Regression tested on x86-64 Fedora 38. Co-Authored-By: Andrew Burgess Reviewed-by: Kevin Buettner Reviewed-By: Eli Zaretskii Approved-By: Andrew Burgess --- gdb/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gdb/main.c') diff --git a/gdb/main.c b/gdb/main.c index cf46f6a..97e04f5 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -654,6 +654,10 @@ captured_main_1 (struct captured_main_args *context) int save_auto_load; int ret = 1; + const char *no_color = getenv ("NO_COLOR"); + if (no_color != nullptr && *no_color != '\0') + cli_styling = false; + #ifdef HAVE_USEFUL_SBRK /* Set this before constructing scoped_command_stats. */ lim_at_start = (char *) sbrk (0); -- cgit v1.1