X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Futil.c;h=bdc194e80c9ce45bde0975d7ef9c5ab4b4482bfd;hp=47da11c1b8b0ce3633e352a8ce26be0ee081ec9b;hb=f2fcd59ffaaa97aaa238089cde5225f0e1086904;hpb=97c4a07df982ee967705022feaba9be33947abf0 diff --git a/src/util.c b/src/util.c index 47da11c1b..bdc194e80 100644 --- a/src/util.c +++ b/src/util.c @@ -641,8 +641,8 @@ int parse_env_file( n = strcspn(p, seperator); if (n >= 2 && - strchr(QUOTES, v[0]) && - v[n-1] == v[0]) + strchr(QUOTES, p[0]) && + p[n-1] == p[0]) v = strndup(p+1, n-2); else v = strndup(p, n); @@ -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);