From 46f64c6fdc59d3ff08096edcfc4003a18387edaf Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Mon, 25 Jul 2022 10:57:10 +1200 Subject: [PATCH] exit with non-zero exit code when script ends with non-zero exit (#6115) --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index c5d9e0cb5d..f5f0481346 100644 --- a/src/main.rs +++ b/src/main.rs @@ -299,6 +299,16 @@ fn main() -> Result<()> { input, is_perf_true(), ); + + let last_exit_code = stack.get_env_var(&engine_state, "LAST_EXIT_CODE"); + if let Some(last_exit_code) = last_exit_code { + let value = last_exit_code.as_integer(); + if let Ok(value) = value { + if value != 0 { + std::process::exit(value as i32); + } + } + } if is_perf_true() { info!("eval_file execution {}:{}:{}", file!(), line!(), column!()); }