mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 10:05:54 +02:00
Make pipe redirections consistent, add err>|
etc. forms (#13334)
# Description Fixes the lexer to recognize `out>|`, `err>|`, `out+err>|`, etc. Previously only the short-style forms were recognized, which was inconsistent with normal file redirections. I also integrated it all more into the normal lex path by checking `|` in a special way, which should be more performant and consistent, and cleans up the code a bunch. Closes #13331. # User-Facing Changes - Adds `out>|` (error), `err>|`, `out+err>|`, `err+out>|` as recognized forms of the pipe redirection. # Tests + Formatting All passing. Added tests for the new forms. # After Submitting - [ ] release notes
This commit is contained in:
@ -149,17 +149,26 @@ fn command_substitution_wont_output_extra_newline() {
|
||||
assert_eq!(actual.out, "bar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic_err_pipe_works() {
|
||||
let actual =
|
||||
nu!(r#"with-env { FOO: "bar" } { nu --testbin echo_env_stderr FOO e>| str length }"#);
|
||||
#[rstest::rstest]
|
||||
#[case("err>|")]
|
||||
#[case("e>|")]
|
||||
fn basic_err_pipe_works(#[case] redirection: &str) {
|
||||
let actual = nu!(
|
||||
r#"with-env { FOO: "bar" } { nu --testbin echo_env_stderr FOO {redirection} str length }"#
|
||||
.replace("{redirection}", redirection)
|
||||
);
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic_outerr_pipe_works() {
|
||||
#[rstest::rstest]
|
||||
#[case("out+err>|")]
|
||||
#[case("err+out>|")]
|
||||
#[case("o+e>|")]
|
||||
#[case("e+o>|")]
|
||||
fn basic_outerr_pipe_works(#[case] redirection: &str) {
|
||||
let actual = nu!(
|
||||
r#"with-env { FOO: "bar" } { nu --testbin echo_env_mixed out-err FOO FOO o+e>| str length }"#
|
||||
r#"with-env { FOO: "bar" } { nu --testbin echo_env_mixed out-err FOO FOO {redirection} str length }"#
|
||||
.replace("{redirection}", redirection)
|
||||
);
|
||||
assert_eq!(actual.out, "7");
|
||||
}
|
||||
|
Reference in New Issue
Block a user