From cb2969002c971d5119b1ab4aea37cd58857588c4 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sat, 1 Jan 2022 18:20:47 +0100 Subject: [PATCH] Fix #210: simplify escape code to clear line Since we just want to clear the complete line, and are already a the beginning of the line, we can use the simpler \e[K which also seems to fix the display resize bug in #210. Signed-off-by: Joachim Wiberg --- src/exec.c | 2 +- src/getty.c | 2 +- src/helpers.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/exec.c b/src/exec.c index 00cb7438..c93717ea 100644 --- a/src/exec.c +++ b/src/exec.c @@ -286,7 +286,7 @@ static void prepare_tty(char *tty, speed_t speed, char *procname, struct rlimit static int activate_console(int noclear, int nowait) { static const char msg[] = "\nPlease press Enter to activate this console."; - static const char clr[] = "\r\e[2K"; + static const char clr[] = "\r\e[K"; static const char cup[] = "\e[A"; struct termios orig; char c; diff --git a/src/getty.c b/src/getty.c index b1313180..3b0abb88 100644 --- a/src/getty.c +++ b/src/getty.c @@ -196,7 +196,7 @@ static int do_login(char *name) static int getty(char *tty, speed_t speed, char *term, char *user) { - const char cln[] = "\r\e[2K\n"; + const char cln[] = "\r\e[K\n"; char name[33]; /* useradd(1) limit at 32 chars */ pid_t sid; diff --git a/src/helpers.c b/src/helpers.c index 845cb2ac..78b32d53 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -227,7 +227,7 @@ void print_banner(const char *heading) return; buf[0] = 0; - strlcat(buf, "\r\e[2K", sizeof(buf)); + strlcat(buf, "\r\e[K", sizeof(buf)); if (progress_style == PROGRESS_CLASSIC) { strlcat(buf, "\e[1m", sizeof(buf)); @@ -312,7 +312,7 @@ void printv(const char *fmt, va_list ap) if (progress_style == PROGRESS_CLASSIC) cprintf("\r%s ", pad(buf, sizeof(buf), ".", sizeof(buf))); else - cprintf("\r\e[2K%s%s", status(3), buf); + cprintf("\r\e[K%s%s", status(3), buf); } void print(int rc, const char *fmt, ...)