Re: [PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-28 Thread Frank Kühndel
Hello,

we fixed the minor issues in the patch, created two tickets (#4096 for
milestone 5 and #4097 for 6) and Sebastian Huber added the fix to the
git sources.

Many thank to all reviewers for their helpful comments.

Greetings,
Frank

On 9/27/20 9:26 AM, Chris Johns wrote:
> On 26/9/20 2:06 am, Joel Sherrill wrote:
>> On Fri, Sep 25, 2020, 10:06 AM Gedare Bloom > > wrote:
>>
>> On Fri, Sep 25, 2020 at 3:11 AM Frank Kuehndel
>> > > wrote:
>> >
>> > 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 ):
>> >
>> > > ~/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 
>> 
>> key. Next type -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
>> >
>>
>> Please put the above bug details into a ticket
>> https://devel.rtems.org/wiki/NewTicket with a milestone of 6
>>
>>
>> Why wouldn't this also be appropriate for 5?
>>
> It is fine for 5 with a ticket.
> 
>> And can anyone confirm this happens on real hardware? Sometimes control
>> characters act funny on simulators.
> It is broken on hardware so the simulator and hardware match.
> 
> Chris
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
> 

-- 

embedded brains GmbH
Frank Kühndel
Dornierstr. 4
82178 Puchheim
Germany
email: frank.kuehn...@embedded-brains.de
Phone: +49-89-18 94 741 - 23
Fax:   +49-89-18 94 741 - 09
PGP: Public key available on request.
PGP: Fingerprint: EE89 0670 B8BE 551A ED4E  FB85 829C 306F 649C 05B9

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-27 Thread Chris Johns
On 26/9/20 2:06 am, Joel Sherrill wrote:
> On Fri, Sep 25, 2020, 10:06 AM Gedare Bloom  > wrote:
> 
> On Fri, Sep 25, 2020 at 3:11 AM Frank Kuehndel
>  > wrote:
> >
> > 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 ):
> >
> > > ~/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 
> 
> key. Next type -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
> >
> 
> Please put the above bug details into a ticket
> https://devel.rtems.org/wiki/NewTicket with a milestone of 6
> 
> 
> Why wouldn't this also be appropriate for 5?
> 

It is fine for 5 with a ticket.

> And can anyone confirm this happens on real hardware? Sometimes control
> characters act funny on simulators.

It is broken on hardware so the simulator and hardware match.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-25 Thread Joel Sherrill
On Fri, Sep 25, 2020, 10:06 AM Gedare Bloom  wrote:

> On Fri, Sep 25, 2020 at 3:11 AM Frank Kuehndel
>  wrote:
> >
> > 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 ):
> >
> > > ~/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
>  key. Next type -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
> >
>
> Please put the above bug details into a ticket
> https://devel.rtems.org/wiki/NewTicket with a milestone of 6
>

Why wouldn't this also be appropriate for 5?

And can anyone confirm this happens on real hardware? Sometimes control
characters act funny on simulators.



> And then use the commit message to briefly describe the fix and with
> "Closes #." to close the ticket.
>
>
>
> > ---
> >  cpukit/libmisc/shell/shell.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
> > index 13ae411f9c..ee65c1be36 100644
> > --- a/cpukit/libmisc/shell/shell.c
> > +++ b/cpukit/libmisc/shell/shell.c
> > @@ -621,11 +621,14 @@ 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++)
> Do not put a space between a function name and its parentheses.
> strlen(line) or strlen( line ) are both acceptable in this code.
> Although, it looks like the surrounding code violates this rule.
>
> Use explicitly {
> > +fputc('\b', out);
> and }
> for one-line blocks.
>
>
> >  }
> >  col = 0;
> >}
> > --
> > 2.26.2
> >
> > ___
> > devel mailing list
> > devel@rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-25 Thread Gedare Bloom
On Fri, Sep 25, 2020 at 3:11 AM Frank Kuehndel
 wrote:
>
> 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 ):
>
> > ~/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  
> key. Next type -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
>

Please put the above bug details into a ticket
https://devel.rtems.org/wiki/NewTicket with a milestone of 6

And then use the commit message to briefly describe the fix and with
"Closes #." to close the ticket.



> ---
>  cpukit/libmisc/shell/shell.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
> index 13ae411f9c..ee65c1be36 100644
> --- a/cpukit/libmisc/shell/shell.c
> +++ b/cpukit/libmisc/shell/shell.c
> @@ -621,11 +621,14 @@ 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++)
Do not put a space between a function name and its parentheses.
strlen(line) or strlen( line ) are both acceptable in this code.
Although, it looks like the surrounding code violates this rule.

Use explicitly {
> +fputc('\b', out);
and }
for one-line blocks.


>  }
>  col = 0;
>}
> --
> 2.26.2
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-25 Thread Frank Kuehndel
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 ):

> ~/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  key. 
Next type -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

---
 cpukit/libmisc/shell/shell.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
index 13ae411f9c..ee65c1be36 100644
--- a/cpukit/libmisc/shell/shell.c
+++ b/cpukit/libmisc/shell/shell.c
@@ -621,11 +621,14 @@ 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;
   }
-- 
2.26.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel