mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 05:35:52 +03: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
Notes:
sideshowbarker
2024-07-17 08:52:37 +09:00
Author: https://github.com/sin-ack Commit: https://github.com/SerenityOS/serenity/commit/fbf91f41e7 Pull-request: https://github.com/SerenityOS/serenity/pull/14605 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/alimpfard
@ -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
|
||||
|
@ -200,9 +200,9 @@ heredoc_entries :: { .*? (heredoc_entry) '\n' } [each heredoc_entries]
|
||||
variable_decls :: identifier '=' expression (' '+ variable_decls)? ' '*
|
||||
| identifier '=' '(' pipe_sequence ')' (' '+ variable_decls)? ' '*
|
||||
|
||||
pipe_sequence :: command '|' pipe_sequence
|
||||
pipe_sequence :: command '|' '&'? pipe_sequence
|
||||
| command
|
||||
| control_structure '|' pipe_sequence
|
||||
| control_structure '|' '&'? pipe_sequence
|
||||
| control_structure
|
||||
|
||||
control_structure[c] :: for_expr
|
||||
|
Loading…
Reference in New Issue
Block a user