Make Semicolon stop on error (#6079)

* introduce external command runs to failed error, and implement semicolon relative logic

* ignore test due to semicolon works

* not raise ShellError for external commands

* update comment

* add relative test in for windows

* fix type-o

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
WindSoilder
2022-07-20 20:44:42 +08:00
committed by GitHub
parent 558cd58d09
commit a35a71fd82
6 changed files with 111 additions and 11 deletions

View File

@ -123,6 +123,21 @@ fn double_quote_does_not_expand_path_glob() {
})
}
#[cfg(not(windows))]
#[test]
fn failed_command_with_semicolon_will_not_execute_following_cmds() {
Playground::setup("external failed command with semicolon", |dirs, _| {
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
^ls *.abc; echo done
"#
));
assert!(!actual.out.contains("done"));
})
}
#[cfg(windows)]
#[test]
fn explicit_glob_windows() {
@ -166,6 +181,21 @@ fn bare_word_expand_path_glob_windows() {
})
}
#[cfg(windows)]
#[test]
fn failed_command_with_semicolon_will_not_execute_following_cmds_windows() {
Playground::setup("external failed command with semicolon", |dirs, _| {
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
^cargo asdf; echo done
"#
));
assert!(!actual.out.contains("done"));
})
}
#[cfg(windows)]
#[test]
// This test case might fail based on the running shell on Windows - CMD vs PowerShell, the reason is