From 89e9aafbb55b76a2bb1c5e78ffd7ccc1b8cfda29 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Apr 2019 23:05:10 +0200 Subject: [PATCH] sh: Support erasing a whole word with WERASE (^W). --- Userland/sh.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Userland/sh.cpp b/Userland/sh.cpp index cf1485552f..cd00a8dd06 100644 --- a/Userland/sh.cpp +++ b/Userland/sh.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -573,6 +574,21 @@ int main(int argc, char** argv) fflush(stdout); continue; } + if (ch == g->termios.c_cc[VWERASE]) { + bool has_seen_nonspace = false; + while (linedx > 0) { + if (isspace(linebuf[linedx - 1])) { + if (has_seen_nonspace) + break; + } else { + has_seen_nonspace = true; + } + putchar(0x8); + --linedx; + } + fflush(stdout); + continue; + } if (ch == g->termios.c_cc[VKILL]) { if (linedx == 0) continue;