diff options
-rw-r--r-- | shell/hush.c | 6 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/continue1.right | 8 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/continue1.tests | 4 |
3 files changed, 17 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c index a2649d069..ab067dd26 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2131,6 +2131,8 @@ static int run_list(struct pipe *pi) | |||
2131 | /* ctrl-C. We just stop doing whatever we were doing */ | 2131 | /* ctrl-C. We just stop doing whatever we were doing */ |
2132 | bb_putchar('\n'); | 2132 | bb_putchar('\n'); |
2133 | } | 2133 | } |
2134 | loop_top = NULL; | ||
2135 | depth_of_loop = 0; | ||
2134 | rcode = 0; | 2136 | rcode = 0; |
2135 | goto ret; | 2137 | goto ret; |
2136 | } | 2138 | } |
@@ -2152,7 +2154,9 @@ static int run_list(struct pipe *pi) | |||
2152 | debug_printf_exec(": rword=%d cond_code=%d skip_more=%d\n", | 2154 | debug_printf_exec(": rword=%d cond_code=%d skip_more=%d\n", |
2153 | rword, cond_code, skip_more_for_this_rword); | 2155 | rword, cond_code, skip_more_for_this_rword); |
2154 | #if ENABLE_HUSH_LOOPS | 2156 | #if ENABLE_HUSH_LOOPS |
2155 | if (rword == RES_WHILE || rword == RES_UNTIL || rword == RES_FOR) { | 2157 | if ((rword == RES_WHILE || rword == RES_UNTIL || rword == RES_FOR) |
2158 | && loop_top == NULL /* avoid bumping depth_of_loop twice */ | ||
2159 | ) { | ||
2156 | /* start of a loop: remember where loop starts */ | 2160 | /* start of a loop: remember where loop starts */ |
2157 | loop_top = pi; | 2161 | loop_top = pi; |
2158 | depth_of_loop++; | 2162 | depth_of_loop++; |
diff --git a/shell/hush_test/hush-misc/continue1.right b/shell/hush_test/hush-misc/continue1.right new file mode 100644 index 000000000..c4a5565bc --- /dev/null +++ b/shell/hush_test/hush-misc/continue1.right | |||
@@ -0,0 +1,8 @@ | |||
1 | A:a | ||
2 | A:b | ||
3 | A:c | ||
4 | OK1 | ||
5 | A:a | ||
6 | A:b | ||
7 | A:c | ||
8 | OK2 | ||
diff --git a/shell/hush_test/hush-misc/continue1.tests b/shell/hush_test/hush-misc/continue1.tests new file mode 100755 index 000000000..72d356660 --- /dev/null +++ b/shell/hush_test/hush-misc/continue1.tests | |||
@@ -0,0 +1,4 @@ | |||
1 | for v in a b c; do echo A:$v; continue 666; done | ||
2 | echo OK1 | ||
3 | for v in a b c; do echo A:$v; continue 666; done | ||
4 | echo OK2 | ||