diff options
author | Thomas Haller <thaller@redhat.com> | 2019-10-07 17:42:17 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-10-08 12:18:20 +0200 |
commit | 597e4b2d1ede9dffbdabaa141a333a2c50bf2c21 (patch) | |
tree | e070fbe72a99124e70f40528b77a547f275cfb8b | |
parent | d0db41c1d48ae326eb12217b553582b6dde19cd9 (diff) | |
download | NetworkManager-597e4b2d1ede9dffbdabaa141a333a2c50bf2c21.tar.gz |
cli: honor NO_COLOR environment variable to prevent automatic ASCII colors
See-also: https://no-color.org/
-rw-r--r-- | clients/cli/nmcli.c | 6 | ||||
-rw-r--r-- | man/nmcli.xml | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index d53416498c..5fbd6d7261 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -456,6 +456,12 @@ check_colors (NmcColorOption color_option, return FALSE; } + if ( color_option == NMC_USE_COLOR_AUTO + && g_getenv ("NO_COLOR")) { + /* https://no-color.org/ */ + return FALSE; + } + term = g_getenv ("TERM"); if (color_option == NMC_USE_COLOR_AUTO) { diff --git a/man/nmcli.xml b/man/nmcli.xml index 203337693c..694ffc3aba 100644 --- a/man/nmcli.xml +++ b/man/nmcli.xml @@ -129,6 +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 + the environment variable.</para> </listitem> </varlistentry> |