hush: fix a corner case of empty "do \n done" structure
No binary (build failed)
—
(log yok)
| @@ -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 */ | |
| @@ -0,0 +1 @@ | |
| + | OK:0 |
| @@ -0,0 +1,4 @@ | |
| + | while false; do |
| + | # bash will require at least ":" here... |
| + | done |
| + | echo OK:$? |