cli: fix handling empty NO_COLOR= variable

An empty value NO_COLOR= should not be treated to disable colors.
This is also what [1] says (changed a while ago [2]).

[1] https://no-color.org/
[2] 99f90e27d0
This commit is contained in:
Thomas Haller 2023-09-14 15:24:58 +02:00 committed by Beniamino Galvani
parent 867db80457
commit 0ac5221c40
2 changed files with 2 additions and 2 deletions

View file

@ -129,7 +129,7 @@
<citerefentry><refentrytitle>terminal-colors.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
Please refer to the <link linkend='colors' endterm='colors.title' /> section for a
list of color names supported by <command>nmcli</command>.</para>
<para>If the environment variable <literal>NO_COLOR</literal> is set (to any value),
<para>If the environment variable <literal>NO_COLOR</literal> is set (to any non-empty value),
then coloring is disabled with mode "auto". Explicitly enabling coloring overrides
the environment variable.</para>
</listitem>

View file

@ -481,7 +481,7 @@ check_colors(NmcColorOption color_option, char **out_palette_str)
return FALSE;
}
if (color_option == NMC_USE_COLOR_AUTO && g_getenv("NO_COLOR")) {
if (color_option == NMC_USE_COLOR_AUTO && nm_str_not_empty(g_getenv("NO_COLOR"))) {
/* https://no-color.org/ */
return FALSE;
}