Fix pipe redirection into complete (#12818)

# Description
Fixes #12796 where a combined out and err pipe redirection (`o+e>|`)
into `complete` still provides separate `stdout` and `stderr` columns in
the record. Now, the combined output will be in the `stdout` column.
This PR also fixes a similar error with the `e>|` pipe redirection.

# Tests + Formatting
Added two tests.
This commit is contained in:
Ian Manske
2024-05-11 15:32:00 +00:00
committed by GitHub
parent b9a7faad5a
commit cab86f49c0
2 changed files with 25 additions and 5 deletions

View File

@ -340,7 +340,13 @@ fn eval_redirection<D: DebugContext>(
}
Ok(Redirection::file(options.create(true).open(path)?))
}
RedirectionTarget::Pipe { .. } => Ok(Redirection::Pipe(next_out.unwrap_or(OutDest::Pipe))),
RedirectionTarget::Pipe { .. } => {
let dest = match next_out {
None | Some(OutDest::Capture) => OutDest::Pipe,
Some(next) => next,
};
Ok(Redirection::Pipe(dest))
}
}
}
@ -367,11 +373,12 @@ fn eval_element_redirection<D: DebugContext>(
} => {
let stderr = eval_redirection::<D>(engine_state, stack, target, None)?;
if matches!(stderr, Redirection::Pipe(OutDest::Pipe)) {
let dest = match next_out {
None | Some(OutDest::Capture) => OutDest::Pipe,
Some(next) => next,
};
// e>| redirection, don't override current stack `stdout`
Ok((
None,
Some(next_out.map(Redirection::Pipe).unwrap_or(stderr)),
))
Ok((None, Some(Redirection::Pipe(dest))))
} else {
Ok((next_out.map(Redirection::Pipe), Some(stderr)))
}