lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z9s8fb6-0Oysrc5j@decadent.org.uk>
Date: Wed, 19 Mar 2025 22:51:57 +0100
From: Ben Hutchings <benh@...ian.org>
To: netdev@...r.kernel.org
Cc: 1088739@...s.debian.org
Subject: [PATCH iproute2 2/2] color: Handle NO_COLOR environment variable in
 default_color_opt()

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@...ian.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;
 }
 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ