1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:47:35 +00:00

sh: Support basic backspacing on the command line.

It's weird that I didn't do this sooner. I don't know how many tims
I've had to retype a misspelled command. :^)
This commit is contained in:
Andreas Kling 2019-01-25 14:23:27 +01:00
parent dfdca9d2a7
commit 6cc1a9d90a

View file

@ -413,10 +413,19 @@ int main(int, char**)
}
}
for (ssize_t i = 0; i < nread; ++i) {
putchar(keybuf[i]);
char ch = keybuf[i];
if (ch == 8) {
if (linedx == 0)
continue;
linebuf[--linedx] = '\0';
putchar(ch);
fflush(stdout);
continue;
}
putchar(ch);
fflush(stdout);
if (keybuf[i] != '\n') {
linebuf[linedx++] = keybuf[i];
if (ch != '\n') {
linebuf[linedx++] = ch;
linebuf[linedx] = '\0';
} else {
runcmd(linebuf);