hush: fix for "while false && true; do echo BUG; break; done". closes 6170
function old new delta run_list 959 941 -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
d35cbad0ef
commit
3beab83e4f
19
shell/hush.c
19
shell/hush.c
@ -7354,7 +7354,7 @@ static int run_list(struct pipe *pi)
|
|||||||
* and we should not execute CMD */
|
* and we should not execute CMD */
|
||||||
debug_printf_exec("skipped cmd because of || or &&\n");
|
debug_printf_exec("skipped cmd because of || or &&\n");
|
||||||
last_followup = pi->followup;
|
last_followup = pi->followup;
|
||||||
continue;
|
goto dont_check_jobs_but_continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_followup = pi->followup;
|
last_followup = pi->followup;
|
||||||
@ -7493,8 +7493,10 @@ static int run_list(struct pipe *pi)
|
|||||||
G.flag_break_continue = 0;
|
G.flag_break_continue = 0;
|
||||||
/* else: e.g. "continue 2" should *break* once, *then* continue */
|
/* else: e.g. "continue 2" should *break* once, *then* continue */
|
||||||
} /* else: "while... do... { we are here (innermost list is not a loop!) };...done" */
|
} /* else: "while... do... { we are here (innermost list is not a loop!) };...done" */
|
||||||
if (G.depth_break_continue != 0 || fbc == BC_BREAK)
|
if (G.depth_break_continue != 0 || fbc == BC_BREAK) {
|
||||||
goto check_jobs_and_break;
|
checkjobs(NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
/* "continue": simulate end of loop */
|
/* "continue": simulate end of loop */
|
||||||
rword = RES_DONE;
|
rword = RES_DONE;
|
||||||
continue;
|
continue;
|
||||||
@ -7502,7 +7504,6 @@ static int run_list(struct pipe *pi)
|
|||||||
#endif
|
#endif
|
||||||
#if ENABLE_HUSH_FUNCTIONS
|
#if ENABLE_HUSH_FUNCTIONS
|
||||||
if (G.flag_return_in_progress == 1) {
|
if (G.flag_return_in_progress == 1) {
|
||||||
/* same as "goto check_jobs_and_break" */
|
|
||||||
checkjobs(NULL);
|
checkjobs(NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -7544,6 +7545,9 @@ static int run_list(struct pipe *pi)
|
|||||||
if (rword == RES_IF || rword == RES_ELIF)
|
if (rword == RES_IF || rword == RES_ELIF)
|
||||||
cond_code = rcode;
|
cond_code = rcode;
|
||||||
#endif
|
#endif
|
||||||
|
check_jobs_and_continue:
|
||||||
|
checkjobs(NULL);
|
||||||
|
dont_check_jobs_but_continue: ;
|
||||||
#if ENABLE_HUSH_LOOPS
|
#if ENABLE_HUSH_LOOPS
|
||||||
/* Beware of "while false; true; do ..."! */
|
/* Beware of "while false; true; do ..."! */
|
||||||
if (pi->next
|
if (pi->next
|
||||||
@ -7555,22 +7559,17 @@ static int run_list(struct pipe *pi)
|
|||||||
/* "while false; do...done" - exitcode 0 */
|
/* "while false; do...done" - exitcode 0 */
|
||||||
G.last_exitcode = rcode = EXIT_SUCCESS;
|
G.last_exitcode = rcode = EXIT_SUCCESS;
|
||||||
debug_printf_exec(": while expr is false: breaking (exitcode:EXIT_SUCCESS)\n");
|
debug_printf_exec(": while expr is false: breaking (exitcode:EXIT_SUCCESS)\n");
|
||||||
goto check_jobs_and_break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rword == RES_UNTIL) {
|
if (rword == RES_UNTIL) {
|
||||||
if (!rcode) {
|
if (!rcode) {
|
||||||
debug_printf_exec(": until expr is true: breaking\n");
|
debug_printf_exec(": until expr is true: breaking\n");
|
||||||
check_jobs_and_break:
|
|
||||||
checkjobs(NULL);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
check_jobs_and_continue:
|
|
||||||
checkjobs(NULL);
|
|
||||||
} /* for (pi) */
|
} /* for (pi) */
|
||||||
|
|
||||||
#if ENABLE_HUSH_JOB
|
#if ENABLE_HUSH_JOB
|
||||||
|
1
shell/hush_test/hush-misc/while4.right
Normal file
1
shell/hush_test/hush-misc/while4.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
Ok:0
|
6
shell/hush_test/hush-misc/while4.tests
Executable file
6
shell/hush_test/hush-misc/while4.tests
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
false
|
||||||
|
while false && echo Not reached; do
|
||||||
|
echo BUG
|
||||||
|
break
|
||||||
|
done
|
||||||
|
echo Ok:$?
|
Loading…
Reference in New Issue
Block a user