summaryrefslogtreecommitdiff
path: root/Shell
AgeCommit message (Collapse)Author
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
2020-10-13Style: Remove uses of NULL, substituting nullptrMatthew L. Curry
2020-10-04Shell: Fix closest command node detection in Pipes and SequencesAnotherTest
This makes --option completions work for pipes and sequences too.
2020-10-04Shell+LibLine: Record the input offset of completionsAnotherTest
This makes the completion entry retain information about how much of the suggestion was part of the string that caused the match.
2020-10-04Shell: Move everything to the Shell namespaceAnotherTest
Also provide a basic default-constructor.
2020-10-04AK: Don't add newline for outf/dbgf/warnf.asynts
In the future all (normal) output should be written by any of the following functions: out (currently called new_out) outln dbg (currently called new_dbg) dbgln warn (currently called new_warn) warnln However, there are still a ton of uses of the old out/warn/dbg in the code base so the new functions are called new_out/new_warn/new_dbg. I am going to rename them as soon as all the other usages are gone (this might take a while.) I also added raw_out/raw_dbg/raw_warn which don't do any escaping, this should be useful if no formatting is required and if the input contains tons of curly braces. (I am not entirely sure if this function will stay, but I am adding it for now.)
2020-10-03Shell: Fix badly worded help string for '--format'AnotherTest
2020-10-03Everywhere: Fix more typosLinus Groh
2020-10-02AK+Format: Do some housekeeping in the format implementation.asynts
2020-10-01Shell: Assert that the same pid is not given to waitpid()AnotherTest
Theoretically, this assertion should never trip (at least, on serenity where we don't really reuse PIDs). This change should be considered temporary, until we figure out whether waitpid() is being called twice (and succeeding) for one given PID.
2020-10-01Shell: Wait for *any* child to change state when receiving a SIGCHLDAnotherTest
This really just works around the core issue, which is that we have no reliable way to know exactly who raised the signal (yet). Fixes #3645, in a very weird (yet apparently standard) way.
2020-10-01Shell: Sneak a way into being a session leaderAnotherTest
2020-09-30Shell: Track line numbers and the positions of some keywordsAnotherTest
2020-09-30Shell: Make 'editor' a member of Shell, and provide a LibShellAnotherTest
2020-09-28Shell: Don't execute scripts interactively.asynts
The following example should illustrate one issue arising from this: $ echo 'exit 1' > example.sh $ Shell example.sh Good-bye! This message is meant to be shown to an interactive user, but not in a shell script.
2020-09-26Shell: Fix use-after-move in alias resolutionAnotherTest
This unbreaks aliases!
2020-09-26Shell: Add live formatting and take an option to enable itAnotherTest
This patchset makes it possible for the shell to format the current buffer of the line editor live, with somewhat accurate cursor tracking. Since this feature is pretty goofy at best, let's keep it off by default for now :^)
2020-09-26Shell: Fix a FIXME in the a test about using functionsAnotherTest
2020-09-26Shell: Add a (very basic) formatterAnotherTest
2020-09-26Shell: Ignore '\\\n' in inputAnotherTest
This allows the user to break a line: ```sh $ echo \ foo ``` is the same as ```sh $ echo foo ```