~emersion/mrsh

ce21d9ab79c312d539b1490b3392a9f139904cd7 — Drew DeVault 5 years ago 0577dcb
Fix exit during a loop clause

This fixes the following script:

while true
do
    exit
done
1 files changed, 3 insertions(+), 1 deletions(-)

M shell/task/loop_clause.c
M shell/task/loop_clause.c => shell/task/loop_clause.c +3 -1
@@ 25,7 25,7 @@ static void task_loop_clause_destroy(struct task *task) {
static int task_loop_clause_poll(struct task *task, struct context *ctx) {
	struct task_loop_clause *tlc = (struct task_loop_clause *)task;

	while (true) {
	while (ctx->state->exit == -1) {
		if (tlc->tasks.condition) {
			int condition_status = task_poll(tlc->tasks.condition, ctx);
			if (condition_status < 0) {


@@ 50,6 50,8 @@ static int task_loop_clause_poll(struct task *task, struct context *ctx) {
			tlc->tasks.body = task_for_command_list_array(tlc->ast.body);
		}
	}

	return ctx->state->exit;
}

static const struct task_interface task_loop_clause_impl = {