diff --git a/crates/nu-command/tests/commands/redirection.rs b/crates/nu-command/tests/commands/redirection.rs index 14ee683f8e..f7371d9cf7 100644 --- a/crates/nu-command/tests/commands/redirection.rs +++ b/crates/nu-command/tests/commands/redirection.rs @@ -1,3 +1,4 @@ +use nu_test_support::fs::{file_contents, Stub::FileWithContent}; use nu_test_support::nu; use nu_test_support::playground::Playground; @@ -65,10 +66,28 @@ fn redirect_out() { }) } +#[test] +fn two_lines_redirection() { + Playground::setup("redirections with two lines commands", |dirs, _| { + nu!( + cwd: dirs.test(), + r#" +def foobar [] { + 'hello' out> output1.txt + 'world' out> output2.txt +} +foobar"#); + let file_out1 = dirs.test().join("output1.txt"); + let actual = file_contents(file_out1); + assert!(actual.contains("hello")); + let file_out2 = dirs.test().join("output2.txt"); + let actual = file_contents(file_out2); + assert!(actual.contains("world")); + }) +} + #[test] fn separate_redirection() { - use nu_test_support::fs::{file_contents, Stub::FileWithContent}; - use nu_test_support::playground::Playground; Playground::setup( "external with both stdout and stderr messages, to different file", |dirs, sandbox| { diff --git a/crates/nu-parser/src/lite_parser.rs b/crates/nu-parser/src/lite_parser.rs index 0a1f97e7bf..5d017a356a 100644 --- a/crates/nu-parser/src/lite_parser.rs +++ b/crates/nu-parser/src/lite_parser.rs @@ -304,6 +304,8 @@ pub fn lite_parse(tokens: &[Token]) -> (LiteBlock, Option) { block.push(curr_pipeline); curr_pipeline = LitePipeline::new(); + last_connector = TokenContents::Pipe; + last_connector_span = None; } }