Skip to content

Commit

Permalink
nsh_parse.c: fix 'while' and 'until' loop condition
Browse files Browse the repository at this point in the history
The loop condition logic was inverted:
  while true; do echo "test"; done
would exit immediately, while using 'until' would stay in the loop.
This is the opposite of how it is supposed to work.
The reason is that 'state' was set wrong because 'whilematch' is a bool.
  • Loading branch information
bkueng authored and LorenzMeier committed Jun 6, 2018
1 parent 7e2f17d commit 36806ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nshlib/nsh_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd,

/* "Push" the old state and set the new state */

state = whilematch == 0 ? NSH_LOOP_WHILE : NSH_LOOP_UNTIL;
state = whilematch ? NSH_LOOP_WHILE : NSH_LOOP_UNTIL;

This comment has been minimized.

Copy link
@davids5

davids5 Aug 13, 2018

Member

@bkueng what is the origin of this? Was this already fixed in upstream? Did it go upstream? Should this be marked BACKPORT?

This comment has been minimized.

Copy link
@bkueng

bkueng Aug 13, 2018

Author Member

Yes I upstreamed it first, it's a BACKPORT, I just did not mark it as such. Here's the reference: #1

enable = nsh_cmdenabled(vtbl);
#ifdef NSH_DISABLE_SEMICOLON
offset = np->np_foffs;
Expand Down

0 comments on commit 36806ba

Please sign in to comment.