mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
Shell: Add the |& construct for piping stderr along with stdout
When |& is typed, stderr will be piped to stdout before the actual piping happens. This behaves basically like a 2>&1 | (and the underlying implementation transforms it to that anyway).
This commit is contained in:
parent
57c8677b5c
commit
fbf91f41e7
2 changed files with 14 additions and 2 deletions
|
@ -510,6 +510,18 @@ RefPtr<AST::Node> Parser::parse_pipe_sequence()
|
|||
|
||||
auto before_pipe = save_offset();
|
||||
consume();
|
||||
auto also_pipe_stderr = peek() == '&';
|
||||
if (also_pipe_stderr) {
|
||||
consume();
|
||||
|
||||
RefPtr<AST::Node> redirection;
|
||||
{
|
||||
auto redirection_start = push_start();
|
||||
redirection = create<AST::Fd2FdRedirection>(STDERR_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
left = create<AST::Join>(left.release_nonnull(), redirection.release_nonnull());
|
||||
}
|
||||
|
||||
if (auto pipe_seq = parse_pipe_sequence()) {
|
||||
return create<AST::Pipe>(left.release_nonnull(), pipe_seq.release_nonnull()); // Pipe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue