mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 06:00:32 +01:00
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.
This commit is contained in:
parent
3f669444ce
commit
0aed7b5be6
1 changed files with 7 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue