mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +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
|
@ -34,6 +34,7 @@ class Fd2FdRedirection;
|
|||
class FunctionDeclaration;
|
||||
class ForLoop;
|
||||
class Glob;
|
||||
class Heredoc;
|
||||
class HistoryEvent;
|
||||
class Execute;
|
||||
class IfCond;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue