diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 821e64b97..bb0cef67a 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -938,7 +938,14 @@ pub fn eval_block( stack, &pipeline.elements[i], input, - redirect_stdout || (i != pipeline.elements.len() - 1), + redirect_stdout + || (i != pipeline.elements.len() - 1) + && (matches!( + pipeline.elements[i + 1], + PipelineElement::Redirection(_, Redirection::Stdout, _) + | PipelineElement::Redirection(_, Redirection::StdoutAndStderr, _) + | PipelineElement::Expression(..) + )), redirect_stderr || ((i < pipeline.elements.len() - 1) && (matches!(