1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 17:28:10 +00:00
serenity/Userland/Shell
Ali Mohammad Pur 3048274f5e 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 :^)
2021-04-29 20:25:56 +02:00
..
Tests Shell/Tests: Replace 'type f -f' with 'type -f f' 2021-04-19 10:07:58 +02:00
AST.cpp Shell: Add support for heredocs 2021-04-29 20:25:56 +02:00
AST.h Shell: Add support for heredocs 2021-04-29 20:25:56 +02:00
Builtin.cpp Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
CMakeLists.txt Shell: Add support for 'immediate' expressions as variable substitutions 2021-03-07 10:59:51 +01:00
Execution.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Formatter.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Formatter.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Forward.h Shell: Add support for heredocs 2021-04-29 20:25:56 +02:00
ImmediateFunctions.cpp Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
Job.cpp Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
Job.h Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
main.cpp AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
NodeVisitor.cpp Shell: Add support for heredocs 2021-04-29 20:25:56 +02:00
NodeVisitor.h Shell: Add support for heredocs 2021-04-29 20:25:56 +02:00
Parser.cpp Shell: Add support for heredocs 2021-04-29 20:25:56 +02:00
Parser.h Shell: Add support for heredocs 2021-04-29 20:25:56 +02:00
Shell.cpp Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
Shell.h Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
SyntaxHighlighter.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
SyntaxHighlighter.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00