summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-07-29 13:36:09 +0000
committerDenis Vlasenko2008-07-29 13:36:09 +0000
commit4554b721ad230cdb5308b9ee61c20729c2c34ae8 (patch)
treefc7e114b9d54e4d8090f106acb31d1f7fe3f2320 /shell/hush.c
parent45cb9f9581f514e1fc731d6d1146e0ee2333066a (diff)
downloadbusybox-4554b721ad230cdb5308b9ee61c20729c2c34ae8.zip
busybox-4554b721ad230cdb5308b9ee61c20729c2c34ae8.tar.gz
hush: small fix for repeated continue and fix for wrong loop depth count
after Ctrl-C; with testcase for first one
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index a2649d0..ab067dd 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2131,6 +2131,8 @@ static int run_list(struct pipe *pi)
/* ctrl-C. We just stop doing whatever we were doing */
bb_putchar('\n');
}
+ loop_top = NULL;
+ depth_of_loop = 0;
rcode = 0;
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",
rword, cond_code, skip_more_for_this_rword);
#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 */
loop_top = pi;
depth_of_loop++;