From e3250575690f85f7b35c4eae585fbbea106e1cb0 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 17 Jan 2022 02:50:49 -0500 Subject: don't update status for commands that are part of control statements --- src/runner/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/runner') diff --git a/src/runner/mod.rs b/src/runner/mod.rs index 63af51b..84be9a1 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -107,12 +107,14 @@ async fn run_commands( stack.push(Frame::If(false)); } if should { + let status = env.latest_status(); run_pipeline(pipeline.clone(), env, shell_write).await?; if let Some(Frame::If(should)) = stack.top_mut() { *should = env.latest_status().success(); } else { unreachable!(); } + env.set_status(status); } pc += 1; } @@ -122,12 +124,14 @@ async fn run_commands( stack.push(Frame::While(false, pc)); } if should { + let status = env.latest_status(); run_pipeline(pipeline.clone(), env, shell_write).await?; if let Some(Frame::While(should, _)) = stack.top_mut() { *should = env.latest_status().success(); } else { unreachable!(); } + env.set_status(status); } pc += 1; } -- cgit v1.2.3-54-g00ecf