mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-02 22:38:01 +00:00
merge: branch 'th/clicolor-force'
Support CLICOLOR_FORCE variable and fix handling of empty NO_COLOR https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1733
This commit is contained in:
commit
673f9d2154
|
@ -129,8 +129,9 @@
|
|||
<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),
|
||||
then coloring is disabled with mode "auto". Explicitly enabling coloring overrides
|
||||
<para>If the environment variable <literal>NO_COLOR</literal> is set (to any non-empty value),
|
||||
then coloring is disabled with mode "auto". If the environment variable <literal>CLICOLOR_FORCE</literal>
|
||||
is set (to any non-empty value), then coloring is enabled with mode "auto". Explicitly enabling coloring overrides
|
||||
the environment variable.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -489,7 +489,9 @@ check_colors(NmcColorOption color_option, char **out_palette_str)
|
|||
term = g_getenv("TERM");
|
||||
|
||||
if (color_option == NMC_USE_COLOR_AUTO) {
|
||||
if (nm_streq0(term, "dumb") || !isatty(STDOUT_FILENO))
|
||||
if (nm_str_not_empty(g_getenv("CLICOLOR_FORCE"))) {
|
||||
color_option = NMC_USE_COLOR_YES;
|
||||
} else if (nm_streq0(term, "dumb") || !isatty(STDOUT_FILENO))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue