summaryrefslogtreecommitdiff
path: root/Shell
AgeCommit message (Collapse)Author
2019-12-25Build: support library and generator dependenciesjoshua stein
Instead of directly manipulating LDFLAGS, set LIB_DEPS in each subdirectory Makefile listing the libraries needed for building/linking such as "LIB_DEPS = Core GUI Draw IPC Core". This adds each library as an -L and -l argument in LDFLAGS, but also adds the library.a file as a link dependency on the current $(PROGRAM). This causes the given library to be (re)built before linking the current $(PROGRAM), but will also re-link any binaries depending on that library when it is modified, when running make from the root directory. Also turn generator tools like IPCCompiler into dependencies on the files they generate, so they are built on-demand when a particular directory needs them. This all allows the root Makefile to just list directories and not care about the order, as all of the dependency tracking will figure it out.
2019-12-20Build: clean up build system, use one shared Makefilejoshua stein
Allow everything to be built from the top level directory with just 'make', cleaned with 'make clean', and installed with 'make install'. Also support these in any particular subdirectory. Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as it runs. Kernel and early host tools (IPCCompiler, etc.) are built as object.host.o so that they don't conflict with other things built with the cross-compiler.
2019-12-17Shell: Tab completion now gives suggestionsJesse Buhagiar
Pushing the TAB key in the shell now prints suggestions to terminal. This makes it easier to the user to actually see what files are available before executing the command they currently have typed.
2019-12-11Shell: Tab completion for pathsWilliam McPherson
If the cursor is in front of a token that is not the first token, we try to split it on the last slash. If there is a slash, the first part is the directory to search and the second part is the token to complete. If there is no slash, we search the current directory and use the entire token for completion. If we find a single match and it's a directory, we add a slash. If it's a normal file, we add a space, unless there already is one. Also renamed cut_mismatching_chars() parameters to be more appropriate.
2019-12-11Shell: Improve tab completion behaviourWilliam McPherson
A space is added if only one match is found, but we avoid adding redundant spaces. We complete "empty" tokens, i.e. when the cursor is at the start of the line or in front of a space. For example: mkdir test cd test touch test chmod +x test export PATH=/home/anon/test Now if you press tab, or space and then tab, you will get "test". Notice that you also get a space. Completion is now done relative to the cursor. You can enter two words and then go back and complete the first one.
2019-12-11Shell: Refactor append/insert procedureWilliam McPherson
This patch just factors out the procedure of adding characters at the cursor position. It makes tab completion code much nicer.
2019-12-11Shell: Improve readability of cache_path()William McPherson
I prefer String::format over StringBuilder here. Also simplified a weird continue statement.
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-12-07Shell: Use _exit() in the forked child if execvp() failsAndreas Kling
If we can't find an executable to exec() after forking, we don't want to run the atexit() handlers in the child process. Just use _exit() instead to avoid this. This was causing us to write out the shell history to ~/.history every time a "command not found" error was printed.
2019-12-05Shell: Cache PATH for faster tab completionWilliam McPherson
This patch reduces the O(n) tab completion to something like O(log(n)). The cache is just a sorted vector of strings and we binary search it to get a string matching our input, and then check the surrounding strings to see if we need to remove any characters. Also we no longer stat each file every time. Also added an #include in BinarySearch since it was using size_t. Oops. If `export` is called, we recache. Need to implement the `hash` builtin for when an executable has been added to a directory in PATH.
2019-12-05Shell: Redirectiong from multiple-digit fdsKarol Baraniecki
2019-12-05Shell: Implement specifying fds in file redirectionKarol Baraniecki
2019-11-01Shell: Exit the shell on (interactive) EOF with empty bufferAndreas Kling
In other words, if the user presses EOF (normally Ctrl+D), we now print out "<EOF>" and exit the shell without error. Fixes #701.
2019-10-30Shell: Properly set and restore termios settings.Drew Stratford
Previously, we did not properly restore termios settings after running built-in commands. This has been fixed by ensuring that we only change the termios settings when we are forking a child process.
2019-10-20Shell: Update termios settings to match line discipline.Drew Stratford
Shell.cpp uses its own line discipline which handles echoing and line editing. Because of this we disable ICANON and ECHO so that we don't get duplicate characters or weird line editing errors. We also revert these settings just before running a command. This is so that commands may run with proper line editing and echoing.
2019-09-30ByteBuffer: Remove pointer() in favor of data()Andreas Kling
We had two ways to get the data inside a ByteBuffer. That was silly.
2019-09-21LibCore: Convert CFile to ObjectPtrAndreas Kling
2019-09-16Shell: Add a "time" builtin to show how long a command took to runAndreas Kling
2019-09-15Shell: Tab completion for programs in PATHwillmcpherson2
This patch adds a function to LineEditor that takes the current shell buffer, searches PATH for the first program that starts with that buffer and then compares that to any other programs starting with the buffer to remove any mismatching characters off the end. The result is appended to the buffer. This may be faster with a data structure but that seems overkill.
2019-09-15Shell: Fixed `pushd` and `popd`Jesse Buhagiar
Fixed a few issues with both `pushd` and `popd`. There was a few typos etcetera causing it to behave errantly in certain situations.
2019-09-15Shell: Added `pushd`, `popd` and `dirs` builtinsJesse Buhagiar
Added a few builtin functions to the shell to make navigating a bit easier in the terminal. `pushd` allows a user to "push" the current directory to the directory stack, and then `cd` to the new directory. `popd` allows the used to take the directory on the top of the stack off before `cd`'ing to it. `dirs` gives the state of the current directory stack. This is only a partial implementation of the `bash` version (gnu.org/software/bash/manual/html_node/Directory-Stack-Builtins.html) , and doesn't include any of the +N or -N commands as of yet.
2019-09-14Shell: Support extremely naive shell script executionAndreas Kling
This patch allows passing a script as an argument to the Shell program. We will read the specified line by line and pass them through the Shell command interpreter. This is not very powerful, but it's a start :^)
2019-09-14Shell: Add POSIX-compliant character escapingAaron Malpas
POSIX.1-2017, Shells & Utilities, section 2.2
2019-09-13Shell: fix crash when using `cd -` and OLDPWD is nullTim Morgan
2019-09-13Shell: Remember previous working dirTim Morgan
...and allow switching back to it with `cd -` Partially addresses #397
2019-09-10Shell: Add support for special parameter that returns PIDMinusGix
2019-09-10Shell: Add support for special parameter that expands to return-code of last ↵MinusGix
program executed
2019-09-10Shell: Add support for getting environment variable valuesMinusGix
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-09-04Shell: Okay I keep messing up this history file code.. actually fix it!Andreas Kling
It's not safe to return a CFile by-value. CFile is a CObjects and they are honestly not very good at being values..
2019-09-04Shell: Oops, don't exit() when ~/.history does not existAndreas Kling
2019-09-04Shell: Don't open ~/.history for writing on startupAndreas Kling
When we only want to read the file, we should open it for reading.
2019-09-02Shell: Added support for ctr-e/a.marprok
By pressing ctr-e/a the cursor goes to the end/beginning of the current line.
2019-09-01Shell: Support semicolons for separating commandsConrad Pankoff
2019-08-18Shell: Support forward deleteConrad Pankoff
2019-07-25Shell: Put failed command exit statuses in the debug output instead.Andreas Kling
It was kinda unpleasant to always see "So-and-so exited with status 123."
2019-07-25Shell: Simply print "cmd: Command not found." for ENOENT on execution.Andreas Kling
This looks a little nicer than 'execvp(cmd): No such file or directory'
2019-07-19Shell: Implement support for terminal clearing with ^L.Andreas Kling
Make LineEditor::get_line() responsible for printing the prompt. That way we can re-prompt after clearing the screen on ^L. This makes the Serenity Terminal feel a little bit more like home :^)
2019-07-14Kernel: Add support for the WSTOPPED flag to the waitpid() syscall.Andreas Kling
This makes waitpid() return when a child process is stopped via a signal. Use this in Shell to catch stopped children and return control to the command line. :^) Fixes #298.
2019-07-09Shell: Remove some unused code.Andreas Kling
2019-07-08Shell: Handle SIGWINCH to get a nice behavior when resizing.Andreas Kling
When resizing the terminal, we now clear the entire current line and reset the shell's LineEditor input state. This makes it look and feel kinda the same as xterm. Fixes #286.
2019-07-08StringView: Rename characters() to characters_without_null_termination().Andreas Kling
This should make you think twice before trying to use the const char* from a StringView as if it's a null-terminated string.
2019-06-30Meta: Removed all gitignore in the source tree only keeping the root oneVAN BOSSUYT Nicolas
2019-06-23add ~/.history file for Shell, stores entire command log and loads recent ↵CallumAttryde
commands into history buffer
2019-06-14Shell: Implement more advanced globbing.Sergey Bugaev
A glob has to be resolved against the directory corresponding to the part of the path it is found in, not the current directory. For example, in /usr/i*/AK/, the glob has to be resolved inside /usr. Moreover, an argument can contain more than one glob, such as /u*/*/?, in which case they have to be resolved recursively. In case a glob matches nothing, the argument should be used as is.
2019-06-07Meta: Tweak .clang-format to not wrap braces after enums.Andreas Kling
2019-06-07Shell: Run clang-format on everything.Andreas Kling
2019-06-07Kernel: Rename FileDescriptor to FileDescription.Andreas Kling
After reading a bunch of POSIX specs, I've learned that a file descriptor is the number that refers to a file description, not the description itself. So this patch renames FileDescriptor to FileDescription, and Process now has FileDescription* file_description(int fd).
2019-06-06Shell: Print the name of each process whose exit status we're reporting.Andreas Kling
2019-06-06Shell: Check the exit status of all spawned child processes.Andreas Kling