Fix return setting last exit code (#14120)

# Description

Fixes #14113 and #14112.

# Tests + Formatting

Added a test.
This commit is contained in:
Ian Manske
2024-10-17 20:05:58 -07:00
committed by GitHub
parent 28b6db115a
commit e911ff4d67
5 changed files with 16 additions and 7 deletions

View File

@@ -287,8 +287,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());
} else if let Some(code) = error.exit_code() {
self.set_last_exit_code(code, Span::unknown());
}
}