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

@ -32,3 +32,9 @@ fn return_works_in_script_with_def_main() {
);
assert!(actual.err.is_empty());
}
#[test]
fn return_does_not_set_last_exit_code() {
let actual = nu!("hide-env LAST_EXIT_CODE; do --env { return 42 }; $env.LAST_EXIT_CODE?");
assert!(matches!(actual.out.as_str(), ""));
}