mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:35:06 +00:00
Shell: Add support for heredocs
Closes #4283. Heredocs are implemented in a way that makes them feel more like a string (and not a weird redirection, a la bash). There are two tunables, whether the string is dedented (`<<-` vs `<<~`) and whether it allows interpolation (quoted key vs not). To the familiar people, this is how Ruby handles them, and I feel is the most elegant heredoc syntax. Unlike the oddjob that is bash, heredocs are treated exactly as normal strings, and can be used _anywhere_ where a string can be used. They are *required* to appear in the same order as used after a newline is seen when parsing the sequence that the heredoc is used in. For instance: ```sh echo <<-doc1 <<-doc2 | blah blah contents for doc1 doc1 contents for doc2 doc2 ``` The typical nice errors are also implemented :^)
This commit is contained in:
parent
7c8d39e002
commit
3048274f5e
7 changed files with 364 additions and 10 deletions
|
@ -101,6 +101,12 @@ void NodeVisitor::visit(const AST::Glob*)
|
|||
{
|
||||
}
|
||||
|
||||
void NodeVisitor::visit(const AST::Heredoc* node)
|
||||
{
|
||||
if (node->contents())
|
||||
node->contents()->visit(*this);
|
||||
}
|
||||
|
||||
void NodeVisitor::visit(const AST::HistoryEvent*)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue