AnotherTest
be395aab9a
Shell: Do not assume that the job has exited after unblock in fg
2020-08-12 11:41:18 +02:00
AnotherTest
7aa5a2bc0f
Shell: Eliminate possible use-after-free in builtin_fg()
...
This fixes a possible UAF where the job might be destroyed in
block_on_job().
2020-08-12 11:41:18 +02:00
AnotherTest
1dc5574245
Shell: Eliminate reference leak in AST::Execute::run()
2020-08-12 11:41:18 +02:00
AnotherTest
ab3e787334
Shell: Moves pipelined processes to one process group
2020-08-12 11:41:18 +02:00
AnotherTest
8a17527bc5
Shell: Show the job id instead of the pid when a job exits in background
2020-08-12 11:41:18 +02:00
Nico Weber
37d5e3e0df
Shell: Fix fd leak with pipes
...
Fixes the problem reported in #3073 . While trying to write a test
for this, I thought I'd use
Shell -c 'for i in $(seq 100) { echo $i }' | head -n 1
but that makes the cpu spin at 100% and doesn't terminate even
with this fix here. But at least piping disasm into head now works.
2020-08-10 20:57:38 +02:00
AnotherTest
69fc91d974
Shell: Cancel a running for loop upon receiving any non-SIGINT signal
...
And keep the old behaviour of needing two interruptions on SIGINT.
2020-08-10 20:50:06 +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
AnotherTest
5ae2f6e9ec
Shell: Stop a for loop upon receiving two consecutive interruptions
...
This does not work perfectly (just like every other shell...), if the
running program handles the signal (SIGINT in this case) and quits
cleanly, the shell cannot detect the interruption.
This is the case with our `sleep(1)`.
2020-08-09 21:08:07 +02:00
Andreas Kling
3b3d158649
Shell: Make Command::redirections a NonnullRefPtrVector
2020-08-07 09:42:12 +02:00
Andreas Kling
c29681cb03
Shell: Make VariableDeclarations::Variable store NonnullRefPtrs
2020-08-07 09:41:04 +02:00
Andreas Kling
e9c602bc83
Shell: Make resolve_without_cast() return NonnullRefPtr<Value>
2020-08-07 09:36:15 +02:00
Andreas Kling
420e809fee
Shell: Store ListValue's values in a NonnullRefPtrVector<Value>
...
A ListValue never stores null Values, so it makes sense to restrict it.
This also propagates use of NonnullRefPtr to the create() helpers.
There's a small bit of awkwardness around the use of initializer_list,
since we cannot directly construct a NonnullRefPtrVector from one.
2020-08-07 09:33:05 +02:00
Andreas Kling
08e5371f44
Shell: Add some obvious move() calls in AST constructors
2020-08-07 09:19:59 +02:00
Nico Weber
3cc9e8ba41
LibLine+Shell: Remove unused split_mechanism
...
It was only read in should_break_token(), which had no callers.
should_break_token() also got `foo\\ bar` and `"foo bar"` wrong.
2020-08-06 20:37:39 +02:00
Andreas Kling
8dd0c391e9
Shell: Make "fg" set the TTY PGID before SIGCONT'ing the job
...
Otherwise the child will get SIGTTIN/SIGTTOU on next TTY I/O.
2020-08-06 15:50:57 +02:00
Andreas Kling
0c6ce063e6
Shell: Print job status after suspending a command
2020-08-06 15:33:04 +02:00
Andreas Kling
22dd5a7021
Shell: Move printing job status into a Job::print_status() helper
...
This is only used by the "jobs" builtin right now, but more soon.
2020-08-06 15:09:49 +02:00
Andreas Kling
d9aecc8e08
Shell: Remove unnecessary ignore() in Shell::custom_event()
...
Ignoring an event means that it will bubble to the parent Core::Object.
This is not necessary here.
2020-08-06 14:27:06 +02:00
Andreas Kling
b8440b12b7
Shell: Store jobs as NonnullRefPtr<Job>
2020-08-06 14:09:13 +02:00
Andreas Kling
5bce0193de
Shell: Make Job constructors private and use a create() helper
...
Also store PGIDs as pid_t since that's what they are.
2020-08-06 13:48:45 +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
ff01cfa08a
Shell: Mark suspended children as such when receiving a SIGCHLD
2020-08-06 10:35:22 +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
Andreas Kling
3cb8ae873c
Shell: Use NonnullRefPtr to simplify some things in the parser/AST
2020-08-04 18:17:16 +02:00
AnotherTest
1d08cab9ab
Shell: Correct FdRedirection inheriting from two RefCounted bases
...
Also add missing calls to `adopt()`.
2020-08-04 13:40:58 +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
f6d4c4f02c
Shell: update cached_path when adding aliases
...
This has the nice side effect of fixing alias completion, because
cached_path is the source of truth for the completion system, and it was
only refreshed (with shell::cache_path()) in the shell's constructor,
before the rc files where loaded (ie no aliases)
This also means that shell::is_runnable can now rely on the cache, and
doesn't have to check the aliases itself.
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
07ea2b672b
Shell: Tweak tests to use 'echo -n' when newlines are significant
2020-07-30 18:47:41 +02:00
AnotherTest
3b3e90714f
Shell: Add tests for '&&' and '||' parsing and evaluation
2020-07-30 18:47:41 +02:00
AnotherTest
c4888f4b5f
Shell: Fix parse mistake in '&&' not being recursive
2020-07-30 18:47:41 +02:00
AnotherTest
4be2cb895c
Shell: Do not assume that wstatus is valid after wait() returns 0
...
According to the linux waitid manpage, the value of wstatus is
unspecified if wait() returns 0, so we should not assume that any
value it holds is correct (including the exit code).
This is only applicable to the Lagom build.
2020-07-30 18:47:41 +02:00
AnotherTest
58308748cb
Shell: Ignore leading semicolons
...
This makes things like `foo&; bar` behave as expected.
Such behaviour is actually closer to the grammar defined in Parser.h
anyway :P
2020-07-27 12:10:29 +02:00
asynts
707d92db61
Refactor: Change the AK::binary_search signature to use AK::Span.
2020-07-26 16:49:06 +02:00
Ben Wiederhake
782db88e82
Shell: Don't crash when autocompleting a non-bare word
...
For example, type 'Hello?' without the quotation marks but with the
question mark, and press TAB.
Previously, this would crash the Shell. Now, it merely refuses
to make any suggestions.
We could do better, but that is too hard for now.
2020-07-25 19:11:10 +02:00
AnotherTest
8e364b9780
Shell: Mark ForLoop as would_execute
...
This fixes #2825 .
2020-07-17 23:18:15 +02:00
AnotherTest
2f731150a2
Shell: Add a test for loops
2020-07-16 16:01:10 +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
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
cd8495f1d4
Shell: Explicitly declare 'environ' to make the macOS Lagom build happy
2020-07-15 00:09:01 +02:00
AnotherTest
dc62371439
Shell: Avoid waiting for jobs that were *just* unblocked
...
This fixes the issue with C-z not suspending the job on the first try.
...and further signal issues when the suspended job is contiued.
2020-07-13 19:48:45 +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
7170df7dd8
Shell: Resolve aliases in builtin_time
2020-07-13 15:12:28 +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
AnotherTest
8d71eb9a6c
Shell: Recursively resolve aliases
2020-07-12 17:45:18 +02:00
Tom
5d9ea2c787
Shell: Pledge sigaction
...
The shell is wiring up signal handlers, and when they get torn
down by Core::EventLoop, they are reset, which requires sigaction.
2020-07-09 21:58:07 +02:00