tree-wide: check colors_enabled() before outputting ANSI color strings

This commit is contained in:
Lennart Poettering
2016-05-30 18:23:08 +02:00
parent 54f8c958f1
commit 7565bb98a4
3 changed files with 15 additions and 8 deletions
+4 -4
View File
@@ -155,14 +155,14 @@ int ask_char(char *ret, const char *replies, const char *text, ...) {
char c;
bool need_nl = true;
if (on_tty())
if (colors_enabled())
fputs(ANSI_HIGHLIGHT, stdout);
va_start(ap, text);
vprintf(text, ap);
va_end(ap);
if (on_tty())
if (colors_enabled())
fputs(ANSI_NORMAL, stdout);
fflush(stdout);
@@ -199,14 +199,14 @@ int ask_string(char **ret, const char *text, ...) {
char line[LINE_MAX];
va_list ap;
if (on_tty())
if (colors_enabled())
fputs(ANSI_HIGHLIGHT, stdout);
va_start(ap, text);
vprintf(text, ap);
va_end(ap);
if (on_tty())
if (colors_enabled())
fputs(ANSI_NORMAL, stdout);
fflush(stdout);