From 2fe257b7afa17a8c3b1d6f8394ae88f3cde5a08c Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 30 Aug 2017 17:19:43 +0200 Subject: [PATCH] getty.c: Handle Ctrl-U properly, erase line to beginning Signed-off-by: Joachim Nilsson --- src/getty.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/getty.c b/src/getty.c index 41d3049c..c21e6a20 100644 --- a/src/getty.c +++ b/src/getty.c @@ -40,6 +40,7 @@ #define _PATH_LOGIN "/bin/login" #endif +#define CTL(x) ((x) ^ 0100) #define print(s) (void)write(STDOUT_FILENO, s, strlen(s)) @@ -203,6 +204,14 @@ static void do_getty(char *tty, char *name, size_t len) np = name; while ((ch = readch(tty)) != '\n') { + if (ch == CTL('U')) { + while (np > name) { + (void)write(1, "\b \b", 3); + np--; + } + continue; + } + if (np < name + len) *np++ = ch; }