Skip to content

Commit 61c232d

Browse files
authored
Merge pull request #30145 from poettering/reset-terminal-line-editing
make terminal line editing work with systemd-firstboot
2 parents 7d4b61d + 5fee4ac commit 61c232d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/basic/terminal-util.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ int ask_string(char **ret, const char *text, ...) {
233233

234234
int reset_terminal_fd(int fd, bool switch_to_text) {
235235
struct termios termios;
236-
int r = 0;
236+
int r;
237237

238238
/* Set terminal to some sane defaults */
239239

@@ -256,7 +256,9 @@ int reset_terminal_fd(int fd, bool switch_to_text) {
256256

257257

258258
/* Set default keyboard mode */
259-
(void) vt_reset_keyboard(fd);
259+
r = vt_reset_keyboard(fd);
260+
if (r < 0)
261+
log_debug_errno(r, "Failed to reset VT keyboard, ignoring: %m");
260262

261263
if (tcgetattr(fd, &termios) < 0) {
262264
r = log_debug_errno(errno, "Failed to get terminal parameters: %m");
@@ -271,7 +273,7 @@ int reset_terminal_fd(int fd, bool switch_to_text) {
271273
termios.c_iflag |= ICRNL | IMAXBEL | IUTF8;
272274
termios.c_oflag |= ONLCR | OPOST;
273275
termios.c_cflag |= CREAD;
274-
termios.c_lflag = ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOPRT | ECHOKE;
276+
termios.c_lflag = ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE;
275277

276278
termios.c_cc[VINTR] = 03; /* ^C */
277279
termios.c_cc[VQUIT] = 034; /* ^\ */
@@ -290,8 +292,7 @@ int reset_terminal_fd(int fd, bool switch_to_text) {
290292
termios.c_cc[VTIME] = 0;
291293
termios.c_cc[VMIN] = 1;
292294

293-
if (tcsetattr(fd, TCSANOW, &termios) < 0)
294-
r = -errno;
295+
r = RET_NERRNO(tcsetattr(fd, TCSANOW, &termios));
295296

296297
finish:
297298
/* Just in case, flush all crap out */

src/firstboot/firstboot.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ static void print_welcome(int rfd) {
131131
pn = os_release_pretty_name(pretty_name, os_name);
132132
ac = isempty(ansi_color) ? "0" : ansi_color;
133133

134+
(void) reset_terminal_fd(STDIN_FILENO, /* switch_to_text= */ false);
135+
134136
if (colors_enabled())
135137
printf("\nWelcome to your new installation of \x1B[%sm%s\x1B[0m!\n", ac, pn);
136138
else

0 commit comments

Comments
 (0)