summaryrefslogtreecommitdiff
path: root/Shell
AgeCommit message (Collapse)Author
2020-12-30AK+Format: Remove TypeErasedFormatParams& from format function.asynts
2020-12-30Shell: Implement a very basic exec builtinWilliam Marlow
Other shells also support a number of other options with exec and some have special behaviour when calling exec with no arguments except redirections. This PR only supports the basic case of replacing the Shell process (or LibShell host process) with the provided command.
2020-12-30AK: Make binary_search signature more generic.asynts
2020-12-29Shell: Fix wrong step value for brace rangesAnotherTest
This fixes numeric ranges like {1..10}.
2020-12-29Shell: Add runtime errors and implement break/continueAnotherTest
Such errors are raised when SyntaxError nodes are executed, and are also used for internal control flow. The 'break' and 'continue' commands are currently only allowed inside for loops, and outside function bodies. This also adds a 'loop' keyword for infinite loops.
2020-12-29Shell: Make for/match/functions put their variables only in the new scopeAnotherTest
Otherwise, a function would, for example, overwrite its parent scope: ```sh foo(x) { } x=1 foo 2 # would make x=2 otherwise ```
2020-12-29Shell: Add a 'glob' builtinAnotherTest
This builtin takes a bunch of strings, resolves them as globs (in the current directory) and prints out the matching entries. Its main use is to allow dynamic glob resolution: ```sh glob "$whatever/*" ```
2020-12-16Shell: Don't run commands with failing redirectionsLinus Groh
Fixes #3423.
2020-12-15Shell: Make Subshell actually create a subshellAnotherTest
Previously, a "subshell" would just be executed in the parent shell.
2020-12-10Shell: Restore the terminal PGID before printing out job status on exitAnotherTest
This fixes the assert tripping when interrupting a foreground job. Also make `bg` mark the job as 'should announce exit'.
2020-12-08Shell: Actually make shebangs workAnotherTest
Also check for executable permissions before actually trying to run, and print a helpful message if not executable. Fixes #4358
2020-12-08Shell: Avoid recreating the event loop before exec()AnotherTest
This stops the local socket creation spam.
2020-12-08Shell: Put background jobs into new process groups tooAnotherTest
Fixes #4345. This was done in 54b453b in the name of "fixing event loop processing in subshells", but I do not see how a new PGID is supposed to affect the event loop. This seems to have been done by mistake, let's see if any tests fail because of this.
2020-12-08Shell: Show termination signal if job did not exit cleanlyAnotherTest
2020-12-08Shell: Silence TCSETPGRP errors when not interactiveAnotherTest
2020-12-08Shell: Replace all dbg()'s with dbgln()AnotherTest
2020-12-08Shell: Make <return> go to a new line when the command is incompleteAnotherTest
"incomplete" meaning that it has a syntax error that can be recovered from by continuing the input.
2020-12-03Shell: Replace one more user-controlled assert with a syntax errorAnotherTest
test-case: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28114&q=label%3AProj-serenity
2020-12-03Shell: Fix bad cast to BarewordLiteralAnotherTest
As found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28109&q=label%3AProj-serenity
2020-11-30Shell: Error out when an expression is nested too deepAnotherTest
That can happen with too many nested parenthesis, for instance. This commit sets the maximum allowed limit to 2048 (seems relatively safe for normal code). Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28105&q=label%3AProj-serenity
2020-11-29Shell: Fix some at_end() bugs and use syntax errors instead of assertingAnotherTest
...in cases where the assert can be directly caused by user input.
2020-11-17Shell: Remove unused private member and includesLenny Maiorani
Problem: - Clang reports unused private member warning in the `Shell::Formatter`. - Vector is not used in the `Shell::Formatter`. Solution: - Remove unused private member variable. - Remove unused includes.
2020-11-01Shell: Do not leak the value of ARGV in nested function callsAnotherTest
2020-11-01Shell: Search for variables in the last frame firstAnotherTest
Otherwise, we'll end up overwriting another frame's variables if the names match up.
2020-11-01Shell: Store LocalFrames as NonnullOwnPtr<LocalFrame> insteadAnotherTest
As Vector<T> will relocate objects to resize, we cannot assume that the address of a specific LocalFrame will stay constant, or that the reference will not be dangling to begin with. Fixes an assertion that fires when a frame push causes the Vector to reallocate.
2020-10-29Shell: Allow parts of globs to be named in match expressionsAnotherTest
This patchset allows a match expression to have a list of names for its glob parts, which are assigned to the matched values in the body of the match. For example, ```sh stuff=foobarblahblah/target_{1..30} for $stuff { match $it { */* as (dir sub) { echo "doing things with $sub in $dir" make -C $dir $sub # or whatever... } } } ``` With this, match expressions are now significantly more powerful!
2020-10-29Shell: Add some basic tests for backgroundingAnotherTest
2020-10-29Shell: Wait for the rest of the members of a pipeline when one exitsAnotherTest
Assuming we were blocking on one to begin with.
2020-10-29Shell: Use kill_job() to kill jobsAnotherTest
2020-10-29Shell: Add redirections to the formatted command stringAnotherTest
2020-10-29Shell: Do not bail early when printing jobs if waitpid() failsAnotherTest
This fixes running `jobs` in a child process. Also makes sure that stdout is flushed when writing jobs out.
2020-10-29Shell: Rename {source,dest}_fd to {old,new}_fdAnotherTest
This makes `Rewiring' much more understandable, and un-confuses the uses of `dup2()'. Also fixes `dup2()' bugs.
2020-10-29Shell: Run builtins that cannot be run in the main process in a new childAnotherTest
e.g. `$(jobs | wc -l)` would blow up horribly otherwise. (it still does)
2020-10-29Shell: Drop all the jobs after killing them in stop_all_jobs()AnotherTest
2020-10-29Shell: Only prompt the user for a second 'exit' when in interactive modeAnotherTest
2020-10-29Shell: Add the `wait' builtinAnotherTest
This builtin...waits...for the jobs it's given (or all the existing jobs).
2020-10-26Shell: Fix `cd' history (and `cdh')AnotherTest
Previously, `cd` would push relative paths (and possibly nonexistent ones too) into its history, so `cdh' would fail everywhere else.
2020-10-26Shell: Use kill() in fg/bg if killpg() failsAnotherTest
A job might not have its own pgid if it's created through run_tail().
2020-10-26Shell: Ensure that jobs going through run_tail() retain should_waitAnotherTest
This allows putting logic in the background as well.
2020-10-26Shell: Make the ENSURE_WAITID_ONCE requirements a bit less strictAnotherTest
waitid() *may* be called many times if a job does not exit, so only assert this fact when the job has in fact exited. Also allows Background nodes to contain non-execute nodes.
2020-10-26Shell: Implement AK::Formatter::format() for AST::CommandAnotherTest
...and use that to display jobs.
2020-10-26Shell: Support HISTFILE environment variableLinus Groh
This allows changing the Shell's history file path.
2020-10-26Shell+LibLine: Move Shell::{load,save}_history() to Line::EditorLinus Groh
This allows us to easily re-use history loading and saving in other programs using Line::Editor, as well as implementing universally recognized HISTCONTROL.
2020-10-25Shell: Fix off-by-one in EOL mark printingAnotherTest
Fixes #3844.
2020-10-25Shell: Add some tests for brace expansionsAnotherTest
2020-10-25Shell: Add support for brace expansionsAnotherTest
This adds support for (basic) brace expansions with the following syntaxes: - `{expr?,expr?,expr?,...}` which is directly equivalent to `(expr expr expr ...)`, with the missing expressions replaced with an empty string literal. - `{expr..expr}` which is a new range expansion, with two modes: - if both expressions are one unicode code point long, the range is equivalent to the two code points and all code points between the two (numerically). - if both expressions are numeric, the range is equivalent to both numbers, and all numbers between the two. - otherwise, it is equivalent to `(expr expr)`. Closes #3832.
2020-10-15Everywhere: Add missing <AK/TemporaryChange.h> includesAndreas Kling
Don't rely on HashTable.h pulling this in.
2020-10-14Shell: Use Node::kind() instead of Node::class_name() in formatterAnotherTest
2020-10-14Shell: Respect input sources' blank lines between sequencesAnotherTest
But collapse them to a single empty line. This makes the generated sources look significantly better.
2020-10-14Shell: Put a space after the match pattern expression when formattingAnotherTest