diff options
author | Frank Kühndel <frank.kuehndel@embedded-brains.de> | 2020-09-24 15:31:41 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-09-28 14:16:06 +0200 |
commit | ffc928b9a2a5e36e1aeb2872c3bef251e3b154da (patch) | |
tree | 263f7360814a61f07bbe4f8458a492bc3c67441d /cpukit/libmisc | |
parent | doxygen: Fix use of getchark() and rtems_putc() (diff) | |
download | rtems-ffc928b9a2a5e36e1aeb2872c3bef251e3b154da.tar.bz2 |
Fixing bug in line editing of the shell with CTRL-U.
This patch fixes a tiny bug in the command line editing of the RTEMS shell.
Typing CTRL-U in the shell should remove all characters left of the cursor.
After pressing CTRL-U, the current implementation does wrongly place the cursor
at the end of the line instead at its beginning.
To reproduce the bug, start the shell and type 'abc123' (no <RETURN>):
> ~/src/rtems $ qemu-system-arm -net none -nographic -M realview-pbx-a9 \
-m 256M -kernel build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl10.exe
> *** BEGIN OF TEST libdl (RTL) 10 ***
> *** TEST VERSION: 6.0.0.d9bdf166644f612dd628fe4951c12c6f8e94ba5f
> *** TEST STATE: USER_INPUT
> *** TEST BUILD: RTEMS_DEBUG RTEMS_NETWORKING RTEMS_POSIX_API RTEMS_SMP
> *** TEST TOOLS: 10.2.1 20200904 \
(RTEMS 6, RSB 31f936a7b74d60bda609a9960c6e1a705ba54974, Newlib a0d7982)
> RTL (libdl) commands: dl, rtl
>
> RTEMS Shell on /dev/foobar. Use 'help' to list commands.
> SHLL [/] # abc123
Then move the cursor onto the '1' by hitting three times the <ARROW-LEFT> key.
Next type <CTRL>-U:
> SHLL [/] # 123
Note that the cursor is at the end of the line (after '3') instead of correctly
at the beginning (on the '1'), now.
Continuing typing 'echo ' incorrectly results in the output:
> SHLL [/] # 123echo 123
The patch changes this behavior so that the cursor in the second last step will
be on the '1' and typing 'echo ' will then correctly reflected as:
> SHLL [/] # echo 123
Close #4097.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libmisc/shell/shell.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c index 13ae411f9c..77214d0be4 100644 --- a/cpukit/libmisc/shell/shell.c +++ b/cpukit/libmisc/shell/shell.c @@ -621,11 +621,16 @@ static int rtems_shell_line_editor( if (col > 0) { int clen = strlen (line); + int bs; strcpy (line, line + col); if (output) { fprintf(out,"\r%s%*c", prompt, clen, ' '); fprintf(out,"\r%s%s", prompt, line); + + for (bs = 0; bs < strlen(line); bs++) { + fputc('\b', out); + } } col = 0; } |