hush: small fix for repeated continue and fix for wrong loop depth count
after Ctrl-C; with testcase for first one
This commit is contained in:
parent
45cb9f9581
commit
4554b721ad
@ -2131,6 +2131,8 @@ static int run_list(struct pipe *pi)
|
|||||||
/* ctrl-C. We just stop doing whatever we were doing */
|
/* ctrl-C. We just stop doing whatever we were doing */
|
||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
}
|
}
|
||||||
|
loop_top = NULL;
|
||||||
|
depth_of_loop = 0;
|
||||||
rcode = 0;
|
rcode = 0;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -2152,7 +2154,9 @@ static int run_list(struct pipe *pi)
|
|||||||
debug_printf_exec(": rword=%d cond_code=%d skip_more=%d\n",
|
debug_printf_exec(": rword=%d cond_code=%d skip_more=%d\n",
|
||||||
rword, cond_code, skip_more_for_this_rword);
|
rword, cond_code, skip_more_for_this_rword);
|
||||||
#if ENABLE_HUSH_LOOPS
|
#if ENABLE_HUSH_LOOPS
|
||||||
if (rword == RES_WHILE || rword == RES_UNTIL || rword == RES_FOR) {
|
if ((rword == RES_WHILE || rword == RES_UNTIL || rword == RES_FOR)
|
||||||
|
&& loop_top == NULL /* avoid bumping depth_of_loop twice */
|
||||||
|
) {
|
||||||
/* start of a loop: remember where loop starts */
|
/* start of a loop: remember where loop starts */
|
||||||
loop_top = pi;
|
loop_top = pi;
|
||||||
depth_of_loop++;
|
depth_of_loop++;
|
||||||
|
8
shell/hush_test/hush-misc/continue1.right
Normal file
8
shell/hush_test/hush-misc/continue1.right
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
A:a
|
||||||
|
A:b
|
||||||
|
A:c
|
||||||
|
OK1
|
||||||
|
A:a
|
||||||
|
A:b
|
||||||
|
A:c
|
||||||
|
OK2
|
4
shell/hush_test/hush-misc/continue1.tests
Executable file
4
shell/hush_test/hush-misc/continue1.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
for v in a b c; do echo A:$v; continue 666; done
|
||||||
|
echo OK1
|
||||||
|
for v in a b c; do echo A:$v; continue 666; done
|
||||||
|
echo OK2
|
Loading…
x
Reference in New Issue
Block a user