summaryrefslogtreecommitdiff
path: root/Shell/main.cpp
AgeCommit message (Collapse)Author
2020-07-06Shell: Keep the TTY on the same pgroup to get tty signalsAnotherTest
This allows the shell to be notified about SIGWINCH even when a child process is running in the foreground.
2020-07-06Shell: Handle the case where the child we're waiting for doesn't existAnotherTest
Normally, this should not happen, as the child should stay around until we do a waitid on it.
2020-07-06Shell: Do not treat the absence of an init script as an errorAnotherTest
2020-07-05Shell: Build as part of Lagom as wellAnotherTest
Bringing the Serenity Shell to your very own host system :^)
2020-07-05Shell: Read and evaluate an init file on startAnotherTest
This behaviour is overridable with the `--skip-init' flag. The default file is at '~/shell-init.sh'
2020-07-05Shell: Use ArgsParser for argument parsingAnotherTest
2020-07-05Shell: Switch to a new parser and ASTAnotherTest
This commit also completely reworks the execution, highlighting and completion model to work with the new AST. New additions: - $(...) stdout captures - fd>&fd redirections - fd>&- redirections (close fd) - read-write redirections (<> path) - completely event-based execution - the weird idea of allowing the user to redirect the shell's own fds - variables in strings - local variables - minimal list support - adding hyperlinks to all paths that exist
2020-06-01LibLine: Handle interrupts againAnotherTest
This commit makes LibLine handle interrupts (as reported via interrupted() and resized()) again. There is a little catch with the shell: ``` $ ls | pipe> <C-c> (prompt stays here until a key is pressed) ```
2020-05-27Shell: Avoid messing with sigaction while waiting for a childAnotherTest
2020-05-27LibLine: Use Core::EventLoop for outer read loopAnotherTest
This commit changes LibLine's internal structure to work in an event loop, and as a result, also switches it to being a Core::Object.
2020-05-26Userland et al: Pledge sigaction when neededSergey Bugaev
* In some cases, we can first call sigaction()/signal(), then *not* pledge sigaction. * In other cases, we pledge sigaction at first, call sigaction()/signal() second, then pledge again, this time without sigaction. * In yet other cases, we keep the sigaction pledge. I suppose these could all be migrated to drop it or not pledge it at all, if somebody is interested in doing that.
2020-05-25Shell: Refuse to be suspended with ^ZAnotherTest
Suspending the shell while interacting with it is pretty weird, so let's just disallow this behaviour.
2020-05-20LibLine: Unify completion hooks and adapt its usersAnotherTest
LibLine should ultimately not care about what a "token" means in the context of its user, so force the user to split the buffer itself. This also allows the users to pick up contextual clues as well, since they have to lex the line themselves. This commit pacthes Shell and the JS repl to better handle completions, so certain wrong behaviours are now corrected as well: - JS repl can now complete "Object . getOw<tab>" - Shell can now complete "echo | ca<tab>" and paths inside strings
2020-05-17Shell: Switch to using Core::EventLoopAnotherTest
This commit refactors Shell to a Core::Object and switches its looping to Core::EventLoop.
2020-05-17Shell: Patch most of the builtins to use Core::ArgsParserAnotherTest
The remaining one is 'pushd', which seems to have relatively complex logic with regards to its arguments.
2020-05-17Shell: Add job control capabilitiesAnotherTest
This patchset adds the `jobs`, `fg` and `bg` builtins.
2020-05-16Shell: Properly handle parser syntax errorsLinus Groh
In the case of a syntax error the shell parser prints an error message to stderr and returns an empty Vector<Command> - in that case we shouldn't try to determine whether or not we can continue parsing but abort immediately - is_complete() expects that *something* was parsed successfully. Fixes #2251.
2020-05-16Shell: Use DirIterator::SkipParentAndBaseDirShannon Booth
2020-05-15Shell: Correct program stop behaviourAnotherTest
Prior to this, we would only wait for program exit; the shell should stop waiting once the program has been stopped. Fixes #2230
2020-05-15Shell: Print correct errno when execvp() failsSergey Bugaev
Amusingly enough, this was caused by yet another bug.
2020-05-13Shell: Break out of continuation when ^C is pressedAnotherTest
This fixes the little issue with Shell not allowing cancellation of commands once they were in continuation mode ``` $ ls ' $ # No matter what we do here, we cannot escape 'ls' ```
2020-05-10Shell: Hyperlink output from "pwd" and "dirs" built-ins :^)Andreas Kling
2020-05-10Shell: Support basic syntax highlightingAnotherTest
2020-05-10Shell: Parse commentsAnotherTest
2020-05-10Shell: Include some metadata in parsed tokens and ask for continuationAnotherTest
This patchset adds some metadata to Parser::parse() which allows the Shell to ask for the rest of a command, if it is not complete. A command is considered complete if it has no trailing pipe, or unterminated string.
2020-05-04Shell: Check for invalid #! in commandsAndrew Kaster
2020-04-30Shell: Provide the correct invariant length to the line editorAnotherTest
2020-04-30Shell+LibLine: Handle escaped characters correctlyAnotherTest
This patchset fixes incorrect handling of escaped tokens (`a\ b`) in Shell autocompletion and LibLine. The users of LibLine can now choose between two token splitting modes, either taking into account escapes, or ignoring them.
2020-04-27Shell: use access() syscall to check if files are executable by userStephan Unverwerth
2020-04-21LibCore: Make Core::File::open() return a Result<NNRP<File>, String>Andreas Kling
It was impractical to return a RefPtr<File> since that left us no way to extract the error string. This is usually needed for the UI, so the old static open() got basically no use.
2020-04-19Shell: Correct suggestion of directoriesAnotherTest
2020-04-19LibLine: Allow suggestions to have trailing trivia stringsAnotherTest
These strings would be applied when inserted into the buffer, but are not shown as part of the suggestion. This commit also patches up Userland/js and Shell to use this functionality
2020-04-19Shell: Don't return early if command is in PATH and a directoryLinus Groh
2020-04-19Shell: Explicitly check if command is a directoryLinus Groh
This is a bit nicer than getting "Exec format error" after trying to execvp() a directory.
2020-04-13Shell: Suggest local executables and directoriesStephan Unverwerth
...when no matching executable could be found in $PATH
2020-04-13Shell: Complete .hidden files if token starts with a dotAnotherTest
2020-04-13Shell: Avoid spamming debug output with suggestionsAnotherTest
2020-04-13Shell: Do not manually write to the editor buffer when completing pathsAnotherTest
2020-04-11LibLine: Display suggestions and cycle between themAnotherTest
With extra color (tm) This commit also patches the users of LibLine to properly use the new API
2020-03-31LibLine: Rename LineEditor.{cpp,h} => Editor.{cpp,h}Andreas Kling
2020-03-31LibLine: Rename LineEditor to Line::EditorAndreas Kling
2020-03-31LibLine: Rename from LibLineEditAndreas Kling
2020-03-31LibLineEdit + Shell: Handle Termios internally and give a copy if askedAnotherTest
This moves the Termios logic inside LibLineEdit and allows users to simply forget about the existence of termios if they so choose to :^)
2020-03-31LibLinEdit + Shell: handle signalsAnotherTest
This allows the LineEditor to get notified about signals, since we cannot set signal handlers in a clean way within the LineEditor instance.
2020-03-31Shell: Move LineEdit out and add it as a dependencyAnotherTest
This builds up on the 'new' LibLineEdit and overrides some of its hooks For instance, on_tab_complete_first_token
2020-03-30Shell: Shorten $HOME to '~' in shell promptsAndreas Kling
The "\w" substitution in shell prompts now uses '~' to represent the user's home directory (technically, whatever $HOME contains.)
2020-03-30Shell: Stop making shell history files world-readableAndreas Kling
\0 pointed out that it's pretty bad to have world-readable .history files, especially for root's shell!
2020-03-22Shell: More general tilde expansionShannon Booth
Now expanding a tilde isn't hardcoded to just work for `cd`. It is instead expanded while processing shell arguments. Autocompletion still doesn't work, but this is definitely an improvement over the last iteration.
2020-03-22Shell: Use starts_with() in expand_parametersShannon Booth
This reads a little nicer, and makes us care less about an empty String
2020-03-22Shell: Use size_t for SH_DEBUG vector iterationShannon Booth
We missed this when switching to size_t for vector sizing as this code is not normally compiled.