Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #86512

Bug#1088739: [PATCH iproute2 2/2] color: Handle NO_COLOR environment variable in default_color_opt()

From Ben Hutchings <benh@debian.org>
Newsgroups linux.debian.bugs.dist, linux.debian.kernel
Subject Bug#1088739: [PATCH iproute2 2/2] color: Handle NO_COLOR environment variable in default_color_opt()
Date 2025-03-19 23:00 +0100
Message-ID <Ks9C9-7hVE-1@gated-at.bofh.it> (permalink)
References <Ks9C9-7hVE-3@gated-at.bofh.it> <JOsqB-cJIc-3@gated-at.bofh.it> <Ks9C9-7hVE-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Cross-posted to 2 groups.

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

The NO_COLOR environment variable is a widely supported way for users
to disable coloured text output.  See <https://no-color.org/>.  In
case iproute2 is configured to use colours by default, allow this to
be overridden by setting NO_COLOR.

This is done in default_color_opt() so that colours can still be
explicitly enabled with a command-line option.

Signed-off-by: Ben Hutchings <benh@debian.org>
---
 lib/color.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/color.c b/lib/color.c
index 5c4cc329..3c6db08d 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -83,6 +83,13 @@ static void enable_color(void)
 
 int default_color_opt(void)
 {
+	const char *no_color;
+
+	/* If NO_COLOR has a non-empty value, coloured output is never wanted */
+	no_color = getenv("NO_COLOR");
+	if (no_color && *no_color)
+		return COLOR_OPT_NEVER;
+
 	return CONF_COLOR;
 }
 

Back to linux.debian.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Bug#1088739: colors make ip's output unreadable Harald Dunkel <harri@afaics.de> - 2024-11-30 11:00 +0100
  Bug#1088739: colors make ip's output unreadable Luca Boccassi <luca.boccassi@gmail.com> - 2024-11-30 12:50 +0100
    Re: Bug#1088739: colors make ip's output unreadable Harald Dunkel <harald.dunkel@aixigo.com> - 2024-12-02 12:20 +0100
      Re: Re: Bug#1088739: colors make ip's output unreadable Luca Boccassi <bluca@debian.org> - 2024-12-03 20:30 +0100
        Re: Bug#1088739: colors make ip's output unreadable Bjørn Mork <bjorn@mork.no> - 2024-12-03 21:00 +0100
    Re: Bug#1088739: colors make ip's output unreadable Harald Dunkel <harald.dunkel@aixigo.com> - 2024-12-02 12:40 +0100
    Bug#1088739: colors make ip's output unreadable Bastian Blank <waldi@debian.org> - 2024-12-21 15:50 +0100
      Bug#1088739: colors make ip's output unreadable Bastian Blank <waldi@debian.org> - 2025-01-02 11:20 +0100
      Bug#1088739: colors make ip's output unreadable Luca Boccassi <bluca@debian.org> - 2025-01-02 21:00 +0100
  Processed: Re: colors make ip's output unreadable "Debian Bug Tracking System" <owner@bugs.debian.org> - 2024-11-30 12:50 +0100
  Re: Bug#1088739: colors make ip's output unreadable Bjørn Mork <bjorn@mork.no> - 2024-11-30 14:50 +0100
  Processed: Re: Bug#1088739: colors make ip's output unreadable "Debian Bug Tracking System" <owner@bugs.debian.org> - 2024-12-21 15:50 +0100
  Processed: Re: Bug#1088739: colors make ip's output unreadable "Debian Bug Tracking System" <owner@bugs.debian.org> - 2025-01-02 21:00 +0100
  Bug#1088739: colors make ip's output unreadable Axel Scheepers <axel.scheepers76@gmail.com> - 2025-01-12 13:30 +0100
  Bug#1088739: colors make ip's output unreadable Harald Dunkel <harri@afaics.de> - 2025-03-18 09:20 +0100
  Bug#1088739: colors make ip's output unreadable "Oliver M. Schode" <oliver.schode@online.de> - 2025-03-19 14:10 +0100
    Bug#1088739: colors make ip's output unreadable Ben Hutchings <ben@decadent.org.uk> - 2025-03-26 17:10 +0100
      Bug#1088739: colors make ip's output unreadable Luca Boccassi <bluca@debian.org> - 2025-03-26 19:00 +0100
  Bug#1088739: [PATCH iproute2 1/2] color: Introduce and use default_color_opt() function Ben Hutchings <benh@debian.org> - 2025-03-19 23:00 +0100
    Bug#1088739: [PATCH iproute2 2/2] color: Handle NO_COLOR environment variable in default_color_opt() Ben Hutchings <benh@debian.org> - 2025-03-19 23:00 +0100
  Bug#1088739: [PATCH iproute2 0/2] Improve coloured text readability Ben Hutchings <benh@debian.org> - 2025-03-26 15:10 +0100
    Bug#1088739: [PATCH iproute2 2/2] color: Do not use dark blue in dark-background palette Ben Hutchings <benh@debian.org> - 2025-03-26 15:20 +0100
    Bug#1088739: [PATCH iproute2 1/2] color: Assume background is dark if unknown Ben Hutchings <benh@debian.org> - 2025-03-26 15:20 +0100
    Bug#1088739: [PATCH iproute2 0/2] Improve coloured text readability patchwork-bot+netdevbpf@kernel.org - 2025-04-06 19:20 +0200
  Bug#1088739: marked as done (colors make ip's output unreadable) "Debian Bug Tracking System" <owner@bugs.debian.org> - 2025-04-06 21:20 +0200

csiph-web