From c6697c150d76efaf858705509e7516c57b96ee6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 6 Jun 2018 12:50:41 +0000 Subject: [PATCH] Merged in bkueng/nuttx-apps (pull request #138) nsh_parse.c: fix 'while' and 'until' loop condition 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. Approved-by: Gregory Nutt --- nshlib/nsh_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c index 0dd2a630a..6018fd894 100644 --- a/nshlib/nsh_parse.c +++ b/nshlib/nsh_parse.c @@ -1552,7 +1552,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; enable = nsh_cmdenabled(vtbl); #ifdef NSH_DISABLE_SEMICOLON offset = np->np_foffs;