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


Groups > linux.debian.kernel > #86511

Bug#1088739: [PATCH iproute2 1/2] color: Introduce and use default_color_opt() function

From Ben Hutchings <benh@debian.org>
Newsgroups linux.debian.bugs.dist, linux.debian.kernel
Subject Bug#1088739: [PATCH iproute2 1/2] color: Introduce and use default_color_opt() function
Date 2025-03-19 23:00 +0100
Message-ID <Ks9C9-7hVE-3@gated-at.bofh.it> (permalink)
References <JOsqB-cJIc-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

As a preparatory step for supporting the NO_COLOR environment
variable, replace the direct use of CONF_COLOR with a
default_color_opt() function which initially returns CONF_COLOR.

Signed-off-by: Ben Hutchings <benh@debian.org>
---
 bridge/bridge.c | 2 +-
 include/color.h | 1 +
 ip/ip.c         | 2 +-
 lib/color.c     | 5 +++++
 tc/tc.c         | 2 +-
 5 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/bridge/bridge.c b/bridge/bridge.c
index f8b5646a..d993ba19 100644
--- a/bridge/bridge.c
+++ b/bridge/bridge.c
@@ -103,7 +103,7 @@ static int batch(const char *name)
 int
 main(int argc, char **argv)
 {
-	int color = CONF_COLOR;
+	int color = default_color_opt();
 
 	while (argc > 1) {
 		const char *opt = argv[1];
diff --git a/include/color.h b/include/color.h
index 17ec56f3..b543c267 100644
--- a/include/color.h
+++ b/include/color.h
@@ -20,6 +20,7 @@ enum color_opt {
 	COLOR_OPT_ALWAYS = 2
 };
 
+int default_color_opt(void);
 bool check_enable_color(int color, int json);
 bool matches_color(const char *arg, int *val);
 int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);
diff --git a/ip/ip.c b/ip/ip.c
index c7151fbd..e4b71bde 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -166,7 +166,7 @@ int main(int argc, char **argv)
 	const char *libbpf_version;
 	char *batch_file = NULL;
 	char *basename;
-	int color = CONF_COLOR;
+	int color = default_color_opt();
 
 	/* to run vrf exec without root, capabilities might be set, drop them
 	 * if not needed as the first thing.
diff --git a/lib/color.c b/lib/color.c
index cd0f9f75..5c4cc329 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -81,6 +81,11 @@ static void enable_color(void)
 	set_color_palette();
 }
 
+int default_color_opt(void)
+{
+	return CONF_COLOR;
+}
+
 bool check_enable_color(int color, int json)
 {
 	if (json || color == COLOR_OPT_NEVER)
diff --git a/tc/tc.c b/tc/tc.c
index beb88111..0fc658c8 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -254,7 +254,7 @@ int main(int argc, char **argv)
 {
 	const char *libbpf_version;
 	char *batch_file = NULL;
-	int color = CONF_COLOR;
+	int color = default_color_opt();
 	int ret;
 
 	while (argc > 1) {

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