From ce21d9ab79c312d539b1490b3392a9f139904cd7 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 29 Sep 2018 16:28:52 -0400 Subject: [PATCH] Fix exit during a loop clause This fixes the following script: while true do exit done --- shell/task/loop_clause.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/task/loop_clause.c b/shell/task/loop_clause.c index db1f6a8..dc43656 100644 --- a/shell/task/loop_clause.c +++ b/shell/task/loop_clause.c @@ -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 = { -- 2.45.2