From: Zbigniew Jędrzejewski-Szmek Date: Tue, 16 Jul 2019 16:48:15 +0000 (+0200) Subject: firstboot: actually accept empty input to mean skip X-Git-Tag: v243-rc1~96^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13080%2Fhead;p=thirdparty%2Fsystemd.git firstboot: actually accept empty input to mean skip We'd loop if the input was empty. We need to return to the caller. --- diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 76d6d1a20c9..bd4944c9684 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -200,38 +200,33 @@ int ask_char(char *ret, const char *replies, const char *fmt, ...) { } int ask_string(char **ret, const char *text, ...) { + _cleanup_free_ char *line = NULL; + va_list ap; int r; assert(ret); assert(text); - for (;;) { - _cleanup_free_ char *line = NULL; - va_list ap; + if (colors_enabled()) + fputs(ANSI_HIGHLIGHT, stdout); - if (colors_enabled()) - fputs(ANSI_HIGHLIGHT, stdout); + va_start(ap, text); + vprintf(text, ap); + va_end(ap); - va_start(ap, text); - vprintf(text, ap); - va_end(ap); + if (colors_enabled()) + fputs(ANSI_NORMAL, stdout); - if (colors_enabled()) - fputs(ANSI_NORMAL, stdout); + fflush(stdout); - fflush(stdout); - - r = read_line(stdin, LONG_LINE_MAX, &line); - if (r < 0) - return r; - if (r == 0) - return -EIO; + r = read_line(stdin, LONG_LINE_MAX, &line); + if (r < 0) + return r; + if (r == 0) + return -EIO; - if (!isempty(line)) { - *ret = TAKE_PTR(line); - return 0; - } - } + *ret = TAKE_PTR(line); + return 0; } int reset_terminal_fd(int fd, bool switch_to_text) {