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>
Signed-off-by: David Ahern <dsahern@kernel.org>
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;
}