shell/hush.c+3 -1
| @@ -2305,8 +2305,10 @@ static int run_list(struct pipe *pi) |
| #endif |
| #if ENABLE_HUSH_LOOPS |
| if (rword == RES_WHILE) { |
| - | if (rcode) |
| + | if (rcode) { |
| + | rcode = 0; /* "while false; do...done" - exitcode 0 */ |
| goto check_jobs_and_break; |
| + | } |
| } |
| if (rword == RES_UNTIL) { |
| if (!rcode) { |
shell/hush_test/hush-misc/break4.right+6 -0
| @@ -0,0 +1,6 @@ |
| + | A |
| + | AA |
| + | TRUE |
| + | A |
| + | AA |
| + | OK:0 |
shell/hush_test/hush-misc/break4.tests+12 -0
| @@ -0,0 +1,12 @@ |
| + | cond=true |
| + | while $cond; do |
| + | echo A |
| + | if test "$cond" = true; then |
| + | cond='echo TRUE' |
| + | else |
| + | cond=false |
| + | fi |
| + | while true; do echo AA; continue 2; echo BB; done |
| + | echo B |
| + | done |
| + | echo OK:$? |
shell/hush_test/hush-misc/while1.right+1 -0
shell/hush_test/hush-misc/while1.tests+2 -0
| @@ -0,0 +1,2 @@ |
| + | while false; do echo NOT SHOWN; done |
| + | echo OK:$? |