diff --git a/sys/shell/shell.c b/sys/shell/shell.c index 5915eeac440f8c3c5a324324cf939c93a9e77ff3..217053a01d1e4819f170474ad3bb0d8cd0ac1e15 100644 --- a/sys/shell/shell.c +++ b/sys/shell/shell.c @@ -235,6 +235,19 @@ static int readline(shell_t *shell, char *buf, size_t size) shell->put_char('\n'); return 0; } + /* QEMU uses 0x7f (DEL) as backspace, while 0x08 (BS) is for most terminals */ + else if (c == 0x08 || c == 0x7f) { + if (line_buf_ptr == buf) { + /* The line is empty. */ + continue; + } + + *--line_buf_ptr = '\0'; + /* white-tape the character */ + shell->put_char('\b'); + shell->put_char(' '); + shell->put_char('\b'); + } else { *line_buf_ptr++ = c; shell->put_char(c);