From: Andrea Claudi <aclaudi@redhat.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org, David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH iproute2-next v3] allow overriding color option in environment
Date: Mon, 18 Sep 2023 22:20:54 +0200 [thread overview]
Message-ID: <ZQixJquSFzcYrWKh@renaissance-vector> (raw)
In-Reply-To: <20230918152910.5325-1-stephen@networkplumber.org>
On Mon, Sep 18, 2023 at 08:29:10AM -0700, Stephen Hemminger wrote:
> For ip, tc, and bridge command introduce IPROUTE_COLORS to enable
> automatic colorization via environment variable.
> Similar to how grep handles color flag.
>
> Example:
> $ IPROUTE_COLORS=auto ip -br addr
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v3 - drop unneccessary check for NULL in match_colors
> all three callers pass valid pointer.
> drop unnecessary check for NULL in default_color
The NULL check in default_color is necessary, because getenv may return
NULL if there is no env variable with the desired name. Indeed it seems
to me this check is maintained in this patch.
However the null string check in default_color is also necessary
because, as I pointed out in the review of the RFC version of this
patch:
IPROUTE_COLORS= ip address
results in colorized output, while I would expect it to produce
colorless output.
This happens because we are effectively passing a null string to
default_color using the above syntax, and match_color_value() treat the
null string as 'always'.
Please note that this is indeed correct when calling match_color_value
when the '-c / --color' option is provided, but not when the env
variable is used to determine the color.
next prev parent reply other threads:[~2023-09-18 20:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 15:29 [PATCH iproute2-next v3] allow overriding color option in environment Stephen Hemminger
2023-09-18 20:20 ` Andrea Claudi [this message]
2023-09-21 1:06 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQixJquSFzcYrWKh@renaissance-vector \
--to=aclaudi@redhat.com \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).