Page 1 of 1

Patch: Backspace characters in the shell

Posted: Thu Oct 09, 2014 3:44 pm
by jbrandmeyer
By default, the PuTTY communication client (my go-to client for serial communications) sends 127 (^?) for the backspace character. Because the shell currently just echoes the character back, it visually appears as though the preceeding character was deleted. However the shell's buffer just fills up with ^? instead. Of course, this doesn't parse well, and the user is left with the impression that the shell doesn't actually handle the backspace character at all.

This impression is easily fixed by handling ^? the same as ^H.

Code: Select all

--- a/os/various/shell.c   Wed Oct 08 15:25:21 2014 -0600
+++ b/os/various/shell.c   Thu Oct 09 08:39:39 2014 -0600
@@ -284,7 +284,7 @@
       chprintf(chp, "^D");
       return TRUE;
     }
-    if (c == 8) {
+    if (c == 8 || c == 127) {
       if (p != line) {
         chSequentialStreamPut(chp, c);
         chSequentialStreamPut(chp, 0x20);


Of course, PuTTY can be configured to send ^H instead as a workaround. But this fact was not at all obvious initially.

Re: Patch: Backspace characters in the shell

Posted: Sat Nov 01, 2014 10:28 am
by Giovanni
Hi,

Change committed in 3.0.0trunk and 2.6.x.

Giovanni