summaryrefslogtreecommitdiff
path: root/src/basic/terminal-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-07-17 14:43:15 +0200
committerGitHub <noreply@github.com>2019-07-17 14:43:15 +0200
commit81c07a955590b44fe2b1f21780df353c0d8b62f6 (patch)
tree5f776c3719887706ac081afe81b9a2c15a7712cf /src/basic/terminal-util.c
parent2a2aeed460d64abd119267efb1a9731acc363bcb (diff)
parent03d9429468c752c8c89f7cec72dcc9f08e86f68b (diff)
downloadsystemd-81c07a955590b44fe2b1f21780df353c0d8b62f6.tar.gz
Merge pull request #13080 from keszybz/firstboot-fixes
Firstboot fixes
Diffstat (limited to 'src/basic/terminal-util.c')
-rw-r--r--src/basic/terminal-util.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 1f39c17306..5b6cd7e316 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) {