diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-04-29 07:04:00 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-29 20:25:56 +0200 |
commit | 3048274f5efdb5a02407d021338faa6770ac5280 (patch) | |
tree | e7bb63202b21fd556de034adb256cafc48fa2380 /Userland/Shell/NodeVisitor.h | |
parent | 7c8d39e00240130615da976da4f1c66ef08fef21 (diff) | |
download | serenity-3048274f5efdb5a02407d021338faa6770ac5280.zip |
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 :^)
Diffstat (limited to 'Userland/Shell/NodeVisitor.h')
-rw-r--r-- | Userland/Shell/NodeVisitor.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Userland/Shell/NodeVisitor.h b/Userland/Shell/NodeVisitor.h index 410bbfa12f..7e7e52e57a 100644 --- a/Userland/Shell/NodeVisitor.h +++ b/Userland/Shell/NodeVisitor.h @@ -30,6 +30,7 @@ public: virtual void visit(const AST::FunctionDeclaration*); virtual void visit(const AST::ForLoop*); virtual void visit(const AST::Glob*); + virtual void visit(const AST::Heredoc*); virtual void visit(const AST::HistoryEvent*); virtual void visit(const AST::Execute*); virtual void visit(const AST::IfCond*); |