Commit Graph

32 Commits

Author SHA1 Message Date
AnotherTest
c589625418 Shell: Allow redirections and pipes on builtins
Fixes #3072.
2020-08-15 20:48:17 +02:00
AnotherTest
9fde92db38 Shell: Make redirections without commands apply to all future commands
This restirects redirection-only commands' scope, and keeps their
usefulness too!
2020-08-09 21:50:33 +02:00
Andreas Kling
b8440b12b7 Shell: Store jobs as NonnullRefPtr<Job> 2020-08-06 14:09:13 +02:00
Andreas Kling
bf2cd9374c Shell: Make run_command() return a NonnullRefPtrVector<Job>
This never returns null Job pointers.
2020-08-06 13:44:30 +02:00
AnotherTest
7b15c85ff5 Shell: Do not assume that stdin/stdout is a TTY
This closes #2989.
2020-08-05 17:30:31 +02:00
AnotherTest
771751258e Shell: Give the TTY to the foreground process
This fixes the bug with the shell not waiting for any foreground process
that attempts to read from the terminal in the Lagom build.
2020-08-04 21:22:44 +02:00
AnotherTest
12af65c1c9 Shell: Add support for ARGV (and $*, $#)
This patchset also adds the 'shift' builtin, as well as the usual tests.
closes #2948.
2020-08-04 13:40:58 +02:00
Mathieu PATUREL
0622b60fbd Shell: factor out updating the path cache into a function. 2020-08-04 10:51:16 +02:00
Mathieu PATUREL
2b4b9d212e Shell: highlight runnable commands
And display in red the command which will result in something like "no
command, or is directory" (inspired by the fish shell).
2020-08-04 10:51:16 +02:00
AnotherTest
b6066faa1f Shell: Add a 'for' loop
Closes #2760.
This commit adds a 'for' loop, and tweaks the syntax slightly to make &&
bind more tightly than || (allowing for `expr && if_ok || if_bad`) :^)
2020-07-16 16:01:10 +02:00
AnotherTest
151e4d41ed Shell: Put children in their own process groups and fix job control
This commit fixes job control by putting children in their own process
group, and proxying TTY signals to active jobs.
This also cleans up the code around builtin_disown a bit to use
the newer job interfaces.
2020-07-13 15:29:16 +02:00
AnotherTest
b0ce8d725a Shell: Move out run_commands and expand_aliases to be Shell member fns
This makes running commands from outside the AST chain easier.
2020-07-13 15:12:28 +02:00
Tom
6dfd503518 Shell: Handle signals asynchronously
Fixes #2717
2020-07-09 21:58:07 +02:00
Andreas Kling
1bc6bb0421 Shell: Run both /etc/shellrc and ~/.shellrc on startup
The global script runs before the local (per-user) one.
2020-07-07 11:35:22 +02:00
AnotherTest
5cdb0ef2e5 Shell: Keep the TTY on the same pgroup to get tty signals
This allows the shell to be notified about SIGWINCH even when a child
process is running in the foreground.
2020-07-06 22:39:32 +02:00
AnotherTest
6d17fe38a4 Shell: Do not treat the absence of an init script as an error 2020-07-06 13:25:42 +02:00
AnotherTest
ff857cd358 Shell: Initial support for 'option' completions
Take one small step towards #2357.
Handle completing barewords starting with '-' by piping the requests to
the Shell::complete_option(program_name, option) :^)

Also implements completion for a single builtin (setopt) until we figure out how
to handle #2357.
2020-07-05 15:43:14 +02:00
AnotherTest
b8d1edb2a2 Shell: Add a 'setopt' builtin
This builtin sets (and unsets) boolean flags that alter the behaviour of
the shell.
The only flags added are
- inline_exec_keep_empty_segments: Keep empty segments in the result of
  splitting $(...) by $IFS
- verbose: Announce each command before executing it

It should be noted that the (rather extreme) verbosity of the names is
intentional, and will hopefully be alleviated by the next commit :^)
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
bc3285abb0 Shell: Read and evaluate an init file on start
This behaviour is overridable with the `--skip-init' flag.
The default file is at '~/shell-init.sh'
2020-07-05 15:43:14 +02:00
AnotherTest
2915dcfcc3 Shell: Add the alias builtin and resolve aliases
This follows the other shells in alias resolution, and resolves the
alias only once.
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
ce61cad933 Shell: Never assign equal job ids to two different jobs
Since the last job need not have an ID of size()-1, we need to find the
max job id and give that+1 out
2020-05-27 11:13:02 +02:00
AnotherTest
d582c03233 Shell: Provide some information to inspectors 2020-05-27 11:13:02 +02:00
AnotherTest
d5e9213683 Shell: Avoid messing with sigaction while waiting for a child 2020-05-27 11:13:02 +02:00
AnotherTest
bc9013f706 LibLine: Change get_line to return a Result<String, Error>
This fixes a bunch of FIXME's in LibLine.
Also handles the case where read() would read zero bytes in vt_dsr() and
effectively block forever by erroring out.

Fixes #2370
2020-05-25 21:36:51 +02:00
AnotherTest
b4ca563637 Shell: Warn the user about active jobs on exit
And make sure that the user means to exit and kill current jobs before exiting.
2020-05-25 00:08:32 +02:00
AnotherTest
143be7234f Shell: Kill existing jobs when exiting 2020-05-25 00:08:32 +02:00
AnotherTest
0d39418b0b Shell: Add the `disown' shell builtin 2020-05-25 00:08:32 +02:00
AnotherTest
7fba21aefc LibLine: Unify completion hooks and adapt its users
LibLine should ultimately not care about what a "token" means in the
context of its user, so force the user to split the buffer itself.
This also allows the users to pick up contextual clues as well, since
they have to lex the line themselves.

This commit pacthes Shell and the JS repl to better handle completions,
so certain wrong behaviours are now corrected as well:
- JS repl can now complete "Object . getOw<tab>"
- Shell can now complete "echo | ca<tab>" and paths inside strings
2020-05-20 13:41:37 +02:00
AnotherTest
1469d20e63 Shell: Treat builtin names as programs and suggest them 2020-05-17 12:54:31 +02:00
AnotherTest
a398898c12 Shell: Switch to using Core::EventLoop
This commit refactors Shell to a Core::Object and switches its looping
to Core::EventLoop.
2020-05-17 11:58:08 +02:00