1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:45:09 +00:00
Commit graph

305 commits

Author SHA1 Message Date
AnotherTest
d4bcc689fb Shell: Make 'for' loops read their input as an stream
i.e. process an element as it becomes available.
2020-08-21 16:00:42 +02:00
AnotherTest
cf18bff72a Shell: Do not attempt to yank the TTY from background processes
They don't own the TTY anyway!
2020-08-19 21:21:34 +02:00
AnotherTest
217eca3d3f Shell: Name the pipe ends correctly 2020-08-19 21:21:34 +02:00
AnotherTest
20d4287eaf Shell: Fix outdated debug log code 2020-08-19 21:21:34 +02:00
AnotherTest
4ee4c94d60 Shell: Respect the 'PROMPT_EOL_MARK' environment variable
This allows the users to customise what is shown when a command ends
without a newline.
2020-08-18 16:58:17 +02:00
AnotherTest
d0aab41628 LibLine: Read configuration from a config file 2020-08-18 12:07:32 +02:00
AnotherTest
14a54a72fa Shell: Ensure that the cursor starts on a new line
And print an indicator when it doesn't, a la zsh.
2020-08-17 17:44:02 +02:00
AnotherTest
154ffa3f5f Shell: Add some tests for builtin redirection 2020-08-15 20:48:17 +02:00
AnotherTest
c589625418 Shell: Allow redirections and pipes on builtins
Fixes #3072.
2020-08-15 20:48:17 +02:00
AnotherTest
d9a1cb440c Shell: Restore input offset when failing to parse a redirection
This fixes #3051
2020-08-14 14:51:31 +02:00
AnotherTest
0950fd1438 Shell: Start writing a man page
This patch adds two man pages describing the parts of the shell that
have been so far finalised.
2020-08-14 10:31:52 +02:00
Nico Weber
924951e426 Shell: Add test for 37d5e3e0df / #3073 2020-08-13 18:45:39 +02:00
Andreas Kling
85b02d887b Shell: Add create() factory function for PathRedirection 2020-08-12 12:15:30 +02:00
Andreas Kling
e8d665337a Shell: Fix another FdRedirection reference leak
Add a create() factory function to prevent this from happening again.
2020-08-12 12:13:33 +02:00
AnotherTest
2b51250863 Shell: Wait for the parent to deal with the PGID stuff before execvp() 2020-08-12 11:41:18 +02:00
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