summaryrefslogtreecommitdiff
path: root/Userland/Shell/Shell.cpp
AgeCommit message (Collapse)Author
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.
2022-03-06Shell: Be more smart with pasted stuffAli Mohammad Pur
Shell can now use LibLine's `on_paste` hook to more intelligently escape pasted data, with the following heuristics: - If the current command is invalid, just pile the pasted string on top - If the cursor is *after* a command node, escape the pasted data, whichever way yields a smaller encoding - If the cursor is at the start of or in the middle of a command name, paste the data as-is, assuming that the user wants to paste code - If the cursor is otherwise in some argument, escape the pasted data according to which kind of string the cursor is in the middle of (double-quoted, single-quoted or a simple bareword)
2022-03-06Shell: Allow completing StringLiterals as pathsAli Mohammad Pur
This auto-escapes the token as well :^)
2022-03-06LibLine+Userland: Make suggestion offsets per-suggestionAli Mohammad Pur
This allows the user to modify different parts of the input with different suggestions.
2022-02-05Shell: Use strncmp() instead of string.compare() for name completionsAli Mohammad Pur
The "at most n bytes" behaviour of strncmp is required for this logic to work, this was overlooked in 5b64abe when converting Strings to StringViews, which lead to broken autocomplete.
2022-01-29Shell: Use StringView instead of String const& where feasibleDaniel Bertalan
2022-01-09Shell: Don't reset 'last_return_code' before running commandsAli Mohammad Pur
Some variables depend on its value to function correctly. Fixes the following issue: $ false; echo $? 1 $ false $ echo $? 128
2022-01-09Shell: Make interrupts kill the whole chain and not just the current jobAli Mohammad Pur
This makes interrupting `sleep 10; echo hi` not print `hi` anymore, which is the expected behaviour anyway. Also fixes the problem with fast-running loops "eating" interrupts and not quitting.
2021-12-31Shell: Make redirection errors raise ShellErrorsAli Mohammad Pur
Naturally, this means that a command with a failing redirection will not start, and so will terminate the pipeline (if any). This also applies to the `exit` run when the shell is closed, fixing a fun bug there as well (thanks to Discord user Salanty for pointing that out) where closing the terminal (i.e. I/O error on the tty) with a failing `exit` command would make the shell retry executing `exit` every time, leading to an eventual stack overflow.
2021-12-30Shell: Avoid many single byte write() syscalls when printing the promptDaniel Bertalan
Whenever the prompt is printed, we write a line's worth of space characters to the terminal to ensure that the prompt ends up on a new line even if there is dangling output on the current line. We write these to the stderr, which is unbuffered, so each putc() call would come with the overhead of a system call. Let's use a buffer + fwrite() instead, since heap allocation is much faster.
2021-12-16Shell: Set subshell flag after checking for its value in parent shellAli Mohammad Pur
This also reverts commit 07cc7eed295a29afef37c4bfaabaf57a3f4af0c1, as that attempted to fix the issue this caused (and succeeded...but it broke something else on linux).
2021-12-11Everywhere: Fix -Winconsistent-missing-override warnings from ClangDaniel Bertalan
This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang.
2021-12-05Shell: Cast unused smart-pointer return values to voidSam Atkins
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-08Shell: Replace Result<T, E> use with ErrorOr<T>Andreas Kling
2021-11-01Everywhere: Remove unused ArgsParser headerBen Wiederhake
Found while trying to enumerate all programs that use ArgsParser.
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-02Userland: Migrate to argument-less deferred_invokesin-ack
Only one place used this argument and it was to hold on to a strong ref for the object. Since we already do that now, there's no need to keep this argument around since this can be easily captured. This commit contains no changes.
2021-08-19AK: Move FormatParser definition from header to implementation fileTimothy Flynn
This is primarily to be able to remove the GenericLexer include out of Format.h as well. A subsequent commit will add AK::Result to GenericLexer, which will cause naming conflicts with other structures named Result. This can be avoided (for now) by preventing nearly every file in the system from implicitly including GenericLexer. Other changes in this commit are to add the GenericLexer include to files where it is missing.
2021-08-12Userland: Fix PATH environment variable orderingJean-Baptiste Boric
2021-08-04Shell: Make sure TTY echo is enabled when running external commandsGunnar Beutner
When running external commands via "Shell -c" LibLine turns of TTY echo before running the command. This ensures that it is turned on.
2021-07-17Shell: Don't assume that only the current shell may continue childrenAli Mohammad Pur
That can happen because of anyone sending the process a SIGCONT. Fixes an issue where continuing a process launched by the shell from the System Monitor would cause the shell to spin on waitpid().
2021-07-13Shell: Add unalias builtinTheFightingCatfish
Add shell unalias builtin to remove aliases
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
2021-06-03Everywhere: Replace ctype.h to avoid narrowing conversionsMax Wipfli
This replaces ctype.h with CharacterType.h everywhere I could find issues with narrowing conversions. While using it will probably make sense almost everywhere in the future, the most critical places should have been addressed.