change display_error.exit_code to false (#13873)

The idea comes from @amtoine, I think it would be good to keey
`display_error.exit_code` same value, if user is using default config or
using no config file at all.
This commit is contained in:
Wind
2024-10-14 22:57:30 +08:00
committed by GitHub
parent a0f38f8845
commit 639bd4fc2e
3 changed files with 14 additions and 9 deletions

View File

@ -627,16 +627,18 @@ fn exit_code_stops_execution_closure() {
assert!(actual.err.contains("exited with code 1"));
}
// TODO: need to add tests under display_error.exit_code = true
#[test]
fn exit_code_stops_execution_custom_command() {
let actual = nu!("def cmd [] { nu -c 'exit 42'; 'ok1' }; cmd; print 'ok2'");
assert!(actual.out.is_empty());
assert!(actual.err.contains("exited with code 42"));
assert!(!actual.err.contains("exited with code 42"));
}
// TODO: need to add tests under display_error.exit_code = true
#[test]
fn exit_code_stops_execution_for_loop() {
let actual = nu!("for x in [0 1] { nu -c 'exit 42'; print $x }");
assert!(actual.out.is_empty());
assert!(actual.err.contains("exited with code 42"));
assert!(!actual.err.contains("exited with code 42"));
}