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:
@@ -7498,7 +7498,10 @@ static int run_list(struct pipe *pi)
|
||||
#endif
|
||||
#if ENABLE_HUSH_LOOPS
|
||||
/* 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 (rcode) {
|
||||
/* "while false; do...done" - exitcode 0 */
|
||||
|
||||
Reference in New Issue
Block a user