hush: fix a corner case of empty "do \n done" structure
The structure is: while cmd; do done bash doesn't accept it at all. We were accepting it but execution was buggy. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
14f55538f0
commit
00ae989ee5
@ -7498,7 +7498,10 @@ static int run_list(struct pipe *pi)
|
|||||||
#endif
|
#endif
|
||||||
#if ENABLE_HUSH_LOOPS
|
#if ENABLE_HUSH_LOOPS
|
||||||
/* Beware of "while false; true; do ..."! */
|
/* Beware of "while false; true; do ..."! */
|
||||||
if (pi->next && pi->next->res_word == RES_DO) {
|
if (pi->next
|
||||||
|
&& (pi->next->res_word == RES_DO || pi->next->res_word == RES_DONE)
|
||||||
|
/* (the second check above is needed for "while ...; do \n done" case) */
|
||||||
|
) {
|
||||||
if (rword == RES_WHILE) {
|
if (rword == RES_WHILE) {
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
/* "while false; do...done" - exitcode 0 */
|
/* "while false; do...done" - exitcode 0 */
|
||||||
|
1
shell/hush_test/hush-misc/while3.right
Normal file
1
shell/hush_test/hush-misc/while3.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
OK:0
|
4
shell/hush_test/hush-misc/while3.tests
Executable file
4
shell/hush_test/hush-misc/while3.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
while false; do
|
||||||
|
# bash will require at least ":" here...
|
||||||
|
done
|
||||||
|
echo OK:$?
|
Loading…
Reference in New Issue
Block a user