diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-02-17 17:57:21 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2016-02-17 19:04:39 +0100 |
commit | 0aed7b5be6950bb994858ecced7308f0c4314fbe (patch) | |
tree | c8ba8faec61f52dfc57efebd6c4696db842fab54 /clients | |
parent | 3f669444ce22b10e9e3b37428bbef403fde09785 (diff) | |
download | NetworkManager-0aed7b5be6950bb994858ecced7308f0c4314fbe.tar.gz |
cli: disable colors on dumb terminals
Nothing too sophisticated; just a simple way to get an color-less output on a
pty that wouldn't confuse the test suite.
Diffstat (limited to 'clients')
-rw-r--r-- | clients/cli/utils.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 898e7f26f6..287778ba24 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -362,8 +362,13 @@ use_colors (NmCli *nmc) if (nmc == NULL) return FALSE; - if (nmc->use_colors == NMC_USE_COLOR_AUTO) - nmc->use_colors = isatty (fileno (stdout)) ? NMC_USE_COLOR_YES : NMC_USE_COLOR_NO; + if (nmc->use_colors == NMC_USE_COLOR_AUTO) { + if ( g_strcmp0 (g_getenv ("TERM"), "dumb") == 0 + || !isatty (fileno (stdout))) + nmc->use_colors = NMC_USE_COLOR_NO; + else + nmc->use_colors = NMC_USE_COLOR_YES; + } return nmc->use_colors == NMC_USE_COLOR_YES; } |