Fix file redirection for externals streams (#12321)

# Description
Fixes `open --raw file o> out.txt` and other instances where
`PipelineData::ExternalStream` is created from sources that are not
external commands.
This commit is contained in:
Ian Manske 2024-03-28 20:22:54 +00:00 committed by GitHub
parent 442faa5576
commit 8e763a2fd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -438,12 +438,12 @@ fn eval_element_with_input_inner<D: DebugContext>(
}
}
let data = match (data, stack.pipe_stdout()) {
(
data @ (PipelineData::Value(..) | PipelineData::ListStream(..)),
Some(IoStream::File(_)),
) => data.write_to_io_streams(engine_state, stack)?,
(data, _) => data,
let data = if matches!(stack.pipe_stdout(), Some(IoStream::File(_)))
&& !matches!(stack.pipe_stderr(), Some(IoStream::Pipe))
{
data.write_to_io_streams(engine_state, stack)?
} else {
data
};
Ok((data, ok))