From b7cda6ed143a8ddc9e240c82f229d0ec88ec8246 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 30 Jun 2019 13:25:14 -0400 Subject: [PATCH] shell: improve reliability Make ASCII_BS (sent when driven through kbd) make the same thing as ASCII_DEL. Also, don't crash on filling the buffer. --- kernel/shell.asm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/shell.asm b/kernel/shell.asm index 63fb3d6..123ca57 100644 --- a/kernel/shell.asm +++ b/kernel/shell.asm @@ -87,6 +87,8 @@ shellLoop: jr z, .do ; char is LF? do! cp ASCII_DEL jr z, .delchr + cp ASCII_BS + jr z, .delchr ; Echo the received character right away so that we see what we type call stdioPutC @@ -98,8 +100,9 @@ shellLoop: xor a ; look for null call findchar ; HL points to where we need to write ; A is the number of chars in the buf - cp SHELL_BUFSIZE - jr z, .do ; A == bufsize? then our buffer is full. do! + cp SHELL_BUFSIZE-1 ; -1 is because we always want to keep our + ; last char at zero. + jr z, .do ; end of buffer reached? buffer is full. do! ; bring the char back in A ex af, af' @@ -124,7 +127,6 @@ shellLoop: ld hl, .prompt call printstr jr shellLoop - ; no ret because we never return .prompt: .db "> ", 0