summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/terminal-util.c8
-rw-r--r--src/journal/journal-verify.c9
-rw-r--r--src/shared/ask-password-api.c6
3 files changed, 15 insertions, 8 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 3189b8789d..2b90f2e5a1 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -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);
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index 26572ddd76..a37316b8f9 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -54,7 +54,9 @@ static void draw_progress(uint64_t p, usec_t *last_usec) {
j = (n * (unsigned) p) / 65535ULL;
k = n - j;
- fputs("\r\x1B[?25l" ANSI_HIGHLIGHT_GREEN, stdout);
+ fputs("\r", stdout);
+ if (colors_enabled())
+ fputs("\x1B[?25l" ANSI_HIGHLIGHT_GREEN, stdout);
for (i = 0; i < j; i++)
fputs("\xe2\x96\x88", stdout);
@@ -66,7 +68,10 @@ static void draw_progress(uint64_t p, usec_t *last_usec) {
printf(" %3"PRIu64"%%", 100U * p / 65535U);
- fputs("\r\x1B[?25h", stdout);
+ fputs("\r", stdout);
+ if (colors_enabled())
+ fputs("\x1B[?25h", stdout);
+
fflush(stdout);
}
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 4a4bd8d3b8..a86b0db554 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -253,10 +253,12 @@ int ask_password_tty(
goto finish;
}
- loop_write(ttyfd, ANSI_HIGHLIGHT, strlen(ANSI_HIGHLIGHT), false);
+ if (colors_enabled())
+ loop_write(ttyfd, ANSI_HIGHLIGHT, strlen(ANSI_HIGHLIGHT), false);
loop_write(ttyfd, message, strlen(message), false);
loop_write(ttyfd, " ", 1, false);
- loop_write(ttyfd, ANSI_NORMAL, strlen(ANSI_NORMAL), false);
+ if (colors_enabled())
+ loop_write(ttyfd, ANSI_NORMAL, strlen(ANSI_NORMAL), false);
new_termios = old_termios;
new_termios.c_lflag &= ~(ICANON|ECHO);