From 475aa4f1dda2a2635a56228b39313d18c69c09bd Mon Sep 17 00:00:00 2001 From: Ian Manske Date: Wed, 2 Oct 2024 04:00:50 -0700 Subject: [PATCH] Fix `LAST_EXIT_CODE` not being set for internal errors (#13954) # Description Fixes #13949 where `$env.LAST_EXIT_CODE` was not being set for internal errors. # Tests + Formatting Cannot test due to limitations with the `nu_repl` test bin. --- crates/nu-protocol/src/engine/stack.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/nu-protocol/src/engine/stack.rs b/crates/nu-protocol/src/engine/stack.rs index 31c1175e7c..391e8633c8 100644 --- a/crates/nu-protocol/src/engine/stack.rs +++ b/crates/nu-protocol/src/engine/stack.rs @@ -286,6 +286,8 @@ impl Stack { pub fn set_last_error(&mut self, error: &ShellError) { if let Some(code) = error.external_exit_code() { self.set_last_exit_code(code.item, code.span); + } else { + self.set_last_exit_code(1, Span::unknown()); } }