summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c
index c1ee936aaf..bdc194e80c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2009,23 +2009,29 @@ int read_one_char(FILE *f, char *ret, bool *need_nl) {
}
int ask(char *ret, const char *replies, const char *text, ...) {
+ bool on_tty;
+
assert(ret);
assert(replies);
assert(text);
+ on_tty = isatty(STDOUT_FILENO);
+
for (;;) {
va_list ap;
char c;
int r;
bool need_nl = true;
- fputs("\x1B[1m", stdout);
+ if (on_tty)
+ fputs("\x1B[1m", stdout);
va_start(ap, text);
vprintf(text, ap);
va_end(ap);
- fputs("\x1B[0m", stdout);
+ if (on_tty)
+ fputs("\x1B[0m", stdout);
fflush(stdout);