summaryrefslogtreecommitdiff
path: root/Userland/Shell/Shell.cpp
AgeCommit message (Collapse)Author
2023-05-30Shell: Prefer File and FileSystem over DeprecatedFileBen Wiederhake
2023-05-30Shell: Rewrite Shell::possibly_print_error without deprecated APIBen Wiederhake
Also, not allocating copies of the current string all the time should be a tiny bit more efficient. We can do this because the 'current_line' is only used while reporting the error, so it will not be used once we begin reading the next line.
2023-05-30Shell: Rewrite Shell::runnable_path_for without deprecated APIBen Wiederhake
Also, not allocating a vector for the parts should be a tiny bit more efficient.
2023-05-19Shell: Prefer File::read_until_eof over DeprecatedFile::read_allBen Wiederhake
2023-05-13Userland: Merge DEFAULT_PATH into LibFileSystem/FileSystem.hBen Wiederhake
2023-05-05Shell: Rename the verb {lookup => look_up}Ali Mohammad Pur
2023-05-05Shell: Place all variables in the closest nonlocal frame in POSIX modeAli Mohammad Pur
2023-04-25Userland: Remove serialize-to-JSON functions only used for InspectorAndreas Kling
2023-04-24Shell: Use `JsonArray::append` in `save_to`Cameron Youell
We can convert it into a failable function here easily
2023-04-24AK: Add new failable `JsonArray::{append/set}` functionsCameron Youell
Move all old usages to the more explicit `JsonArray:must_{append/set}`
2023-04-12Shell: Add `map_fixed` to the pledges for command autocompletionTim Schumacher
2023-03-06Everywhere: Stop using NonnullOwnPtrVectorAndreas Kling
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06Everywhere: Stop using NonnullRefPtrVectorAndreas Kling
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-02-28Everywhere: Use '_{short_,}string' literals moreLinus Groh
This mostly updates code what was written before but merged after these were added.
2023-02-28Shell: Convert all immediately convertible fallible functions to ErrorOrAli Mohammad Pur
2023-02-28Shell: Convert the remaining fallible AST functions to ErrorOrAli Mohammad Pur
2023-02-28Shell: Convert builtins to use the modern main() styleAli Mohammad Pur
That is, return ErrorOr<int>, handle fallible ops with TRY() and accept a Main::Arguments. Note that we do not populate the argc/argv members of Main::Arguments, so all accesses have to go through .strings.
2023-02-28Shell: Make AST::dump() ErrorOr-awareAli Mohammad Pur
2023-02-28Shell+LibCodeComprehension: Start replacing {Deprecated => }StringAli Mohammad Pur
This starts by switching all AST members to Strings, and dealing with the fallout.
2023-02-21Shell: Fix (and paper over) various const-correctness issuesAndreas Kling
2023-02-18Shell: Allow the heredoc node to act as a redirection tooAli Mohammad Pur
This will be used in a future commit to implement POSIX sh heredocs.
2023-02-13Shell: Start implementing a POSIX-compliant parserAli Mohammad Pur
The parser is still very much a work-in-progress, but it can currently parse most of the basic bits, the only *completely* unimplemented things in the parser are: - heredocs (io_here) - alias expansion - arithmetic expansion There are a whole suite of bugs, and syntax highlighting is unreliable at best. For now, this is not attached anywhere, a future commit will enable it for /bin/sh or a `Shell --posix` invocation.
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-01-27AK: Remove StringBuilder::build() in favor of to_deprecated_string()Linus Groh
Having an alias function that only wraps another one is silly, and keeping the more obvious name should flush out more uses of deprecated strings. No behavior change.
2023-01-27Shell: Replace uses of JsonObject::get_deprecated()/get_ptr()Sam Atkins
2023-01-17AK+Everywhere: Rename JsonObject::get() to ::get_deprecated()Sam Atkins
This is a preparatory step to making `get()` return `ErrorOr`.
2023-01-12LibCore+Userland: Make Core::Timer::create_single_shot() return ErrorOrSam Atkins
clang-format sure has some interesting opinions about where to put a method call that comes after a lambda. :thonk:
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-10-10Userland: Remove unecessary uses of __serenity__ macroAndrew Kaster
2022-09-12Shell: Sort CompletionSuggestions for paths lexicographicallyBen Wiederhake
This used to be ordered by inode, which can be surprising.
2022-08-23Userland: Consolidate most PATH resolving into a single implementationTim Schumacher
We previously had at least three different implementations for resolving executables in the PATH, all of which had slightly different characteristics. Merge those into a single implementation to keep the behaviour consistent, and maybe to make that implementation more configurable in the future.
2022-08-23Userland: Rely on a single authoritative source for the default `PATH`Tim Schumacher
2022-07-12Everywhere: Replace single-char StringView op. arguments with charssin-ack
This prevents us from needing a sv suffix, and potentially reduces the need to run generic code for a single character (as contains, starts_with, ends_with etc. for a char will be just a length and equality check). No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12Everywhere: Explicitly specify the size in StringView constructorssin-ack
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
2022-07-08Userland: Add `/usr/local/sbin` to `PATH` by defaultTim Schumacher
`e2fsprogs` adds its tools there.
2022-06-24Shell: Ignore SIGCHLD after a few unsuccessful attempts at handling itAli Mohammad Pur
As noted by the comment, a stray SIGCHLD can make the shell go into an infinite loop, pretend the signal doesn't exist after trying 10 times in 5ms.
2022-04-21Shell: Highlight commands with a hyperlink to open their help pagesForLoveOfCats
2022-04-18Shell: Make program-based completion with no actual token possibleAli Mohammad Pur
31ca48e made this default to paths, but now that we have a few sensible ways to complete things, let's make those work too. For instance, prior to this `kill <tab>` would've suggested paths, but now it will suggest processes.
2022-04-18LibLine: Make it possible to avoid autocompletion if requestedAli Mohammad Pur
Setting 'allow_commit_without_listing' to false will now make LibLine show the suggestion before actually committing to it; this is useful for completions that will replace all the user input, where mistakes can go unnoticed without some visual cue.
2022-04-18LibLine: Respect the provided completion static offsetAli Mohammad Pur
Now that we can resolve these correctly and they're per-suggestion, we can finally use them for their intended purpose of letting suggestions overwrite stuff in the buffer.
2022-04-18Shell: Allow completions to request further action from the shellAli Mohammad Pur
The shell now expects a JSON object of the form {"kind":<kind>,...} per line in the standard output of the completion process, where 'kind' is one of: - "plain": Just a plain suggestion. - "program": Prompts the shell to complete a program name starting with the given "name". - "proxy": Prompts the shell to act as if a completion for "argv" was requested. - "path": Prompts the shell to complete a path given the "base" and "part" (same as completing part in cwd=base).
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-29Shell: Add a shell option for autocompleting via the program itselfAli Mohammad Pur
This feature needs a bit more work, so let's disable it by default. Note that the shell will still use _complete_foo if it is defined regardless of this setting.
2022-03-27Shell: Keep the stdio and rpath pledges for execute_process()Ali Mohammad Pur
If the command fails, we'd like to still be capable of printing out diagnostics, so restore stdio and rpath. Fixes #13281.
2022-03-26Shell: Limit the access of processes spawned for autocompletionAli Mohammad Pur
This commit limits the autocomplete processes to effectively have readonly access to the fs, and only enough pledges to get the dynamic loader working.
2022-03-26Shell+LibCore: Provide argument help strings as display triviaAli Mohammad Pur
2022-03-26Shell: Implement program-aware autocompletionAli Mohammad Pur
A program can either respond to `--complete -- some args to complete` directly, or add a `_complete_<program name>` invokable (i.e. shell function, or just a plain binary in PATH) that completes the given command and lists the completions on stdout. Should such a completion fail or yield no results, we'll fall back to the previous completion algorithm.