Commit graph

29 commits

Author SHA1 Message Date
AnotherTest
95fc7dd03a Shell: Parse lists serially, and flatten them only when needed
This allows `((1 2 3) (4 5 6))` to remain nested until we explicitly
flatten it out.
2020-07-16 16:01:10 +02:00
Peter Elliott
9c1da8fca1 Shell: Remove '[' and ']' as special shell characters
This makes the test utility work, when invoked as '['
2020-07-16 16:00:51 +02:00
AnotherTest
b5e04cb070 Shell: Skip creating a Join node when nothing was parsed
This fixes a crash when Shell tries to highlight `|`.
2020-07-07 14:52:53 +02:00
AnotherTest
f9d3055691 Shell: Do not treat the ending newline as part of a comment
This allows the parser to finally parse the entire source into a single
AST.
As a result of allowing comments inside sequences, Sequence is also
marked as would_execute if its left or right node would.
2020-07-06 13:25:42 +02:00
AnotherTest
d6de2b5828 Shell: Show descriptions about syntax errors
The description contains an error message and where in the source the
error happened.
2020-07-05 15:43:14 +02:00
AnotherTest
034be8e74c Shell: Allow a command sequence to be delimited by newlines 2020-07-05 15:43:14 +02:00
AnotherTest
d2bdbc3e77 Shell: Mark And and Or nodes as execute nodes 2020-07-05 15:43:14 +02:00
AnotherTest
3a37e8c56f Shell: Provide completions to Tilde and its Juxtaposition.
This commit also removes the ExecutionInputType and directly uses
RefPtr<Shell> instead, since nothing else is needed for execution
purposes, and also makes the shell refuse to evaluate commands with
any sort of syntax error.
2020-07-05 15:43:14 +02:00
AnotherTest
c5d0aa9a44 Shell: Allow commands in variables, and properly substitute them on use
This allows the below interaction to work:
```
$ silence=(2>&1 >/dev/null)
$ do_noisy_thing with these args $silence
<nothing here lol>
```
2020-07-05 15:43:14 +02:00
AnotherTest
42304d7bf1 Shell: Parse a pipe sequence inside $(...) 2020-07-05 15:43:14 +02:00
AnotherTest
8e078cf4ab Shell: Expand Juxtaposition of lists to list products
This commit makes `echo x(foo bar)` create an argv of `echo xfoo xbar`,
essentially modeling brace expansions in some shells.
2020-07-05 15:43:14 +02:00
AnotherTest
a4627f2439 Shell: Switch to a new parser and AST
This commit also completely reworks the execution, highlighting and
completion model to work with the new AST.
New additions:
- $(...) stdout captures
- fd>&fd redirections
- fd>&- redirections (close fd)
- read-write redirections (<> path)
- completely event-based execution
- the weird idea of allowing the user to redirect the shell's own fds
- variables in strings
- local variables
- minimal list support
- adding hyperlinks to all paths that exist
2020-07-05 15:43:14 +02:00
AnotherTest
2714bba3f0 Shell: Highlight redirections 2020-06-08 09:27:51 +02:00
AnotherTest
77039e5354 Shell: Correctly complete paths in redirections
This commit allows the Shell to complete paths in redirections.
A closing quote is added if the path is an unclosed quote.
```
$ foo > "foob<tab>
$ foo > "foobar"
```
2020-05-30 00:36:51 +02:00
AnotherTest
c23c354779 Shell: Parse and correctly evaluate 'command &' and 'command &&'
This commit adds the InBackground and ShortCircuitOnFailure attributes
to commands, which respectively cause the command to be run in the
background, and abort the command chain with exit status != 0.
2020-05-25 00:08:32 +02:00
AnotherTest
1d0d0e9d00 Shell: Parse comments 2020-05-10 10:23:05 +02:00
AnotherTest
a862c230b1 Shell: Include some metadata in parsed tokens and ask for continuation
This patchset adds some metadata to Parser::parse() which allows the
Shell to ask for the rest of a command, if it is not complete.
A command is considered complete if it has no trailing pipe, or
unterminated string.
2020-05-10 10:23:05 +02:00
AnotherTest
fb63b84c78 Shell: Correctly parse quoted filenames in redirection
This commit fixes the (incorrect) behaviour of treating quotes as part
of the redirection filename.

Fixes #1857 :^)
2020-04-30 08:51:54 +02:00
Andreas Kling
ed90d39cd7 Shell: Allow empty tokens if enclosed in single or double quotes
Previously the shell parser would discard empty tokens. We now allow
them when they are enclosed in quotes (either '' or "")

This means that a command like _echo ""_ will actually pass an empty
string to /bin/echo in argv[1] now.
2020-01-25 12:16:45 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling
6f4c380d95 AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
2019-12-09 17:51:21 +01:00
Karol Baraniecki
431abc8846 Shell: Redirectiong from multiple-digit fds 2019-12-05 17:08:37 +01:00
Karol Baraniecki
7ed8a468ec Shell: Implement specifying fds in file redirection 2019-12-05 17:08:37 +01:00
Aaron Malpas
f44e7dc5d0 Shell: Add POSIX-compliant character escaping
POSIX.1-2017, Shells & Utilities, section 2.2
2019-09-14 12:45:01 +02:00
Conrad Pankoff
6bb6176762 Shell: Support semicolons for separating commands 2019-09-01 12:44:33 +02:00
Andreas Kling
f7ede145b4 Shell: Run clang-format on everything. 2019-06-07 11:49:21 +02:00
Andreas Kling
848044b74c Shell: Separate fd rewirings from redirections.
This was unnecessarily confusing. When we build up a chain of commands
connected by pipes, we now store the file descriptors of each end of
these pipes as rewirings in a vector. The rewirings are then put into
effect by calls to dup2().
2019-06-04 20:36:08 +02:00
Robin Burchell
aee99b05a6 Shell: Add append operator (>>)
Fixes #93.
2019-05-26 01:32:05 +02:00
Andreas Kling
fe73543d41 Shell: Move the Shell to a separate directory and let's call it "Shell" :^) 2019-05-07 01:12:08 +02:00