summaryrefslogtreecommitdiff
path: root/Userland/Shell
AgeCommit message (Collapse)Author
2021-06-17Everywhere: Add component declarationsGunnar Beutner
This adds component declarations so that users can select to not build certain parts of the OS.
2021-06-16Shell: Remove unused InlineLinkedList header includeBrian Gianforcaro
2021-06-13Userland: Allow building SerenityOS with -funsigned-charGunnar Beutner
Some of the code assumed that chars were always signed while that is not the case on ARM hosts. Also, some of the code tried to use EOF (-1) in a way similar to what fgetc() does, however instead of storing the characters in an int variable a char was used. While this seemed to work it also meant that character 0xFF would be incorrectly seen as an end-of-file. Careful reading of fgetc() reveals that fgetc() stores character data in an int where valid characters are in the range of 0-255 and the EOF value is explicitly outside of that range (usually -1).
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-08Shell: Make `time` stop parsing options on first non-optionJelle Raaijmakers
2021-06-08LibCore: Support fine-grained failure behavior for ArgsParserJelle Raaijmakers
2021-06-07LibWeb+LibSyntax: Implement nested syntax highlightersAli Mohammad Pur
And use them to highlight javascript in HTML source. This commit also changes how TextDocumentSpan::data is interpreted, as it used to be an opaque pointer, but everyone stuffed an enum value inside it, which made the values not unique to each highlighter; that field is now a u64 serial id. The syntax highlighters don't need to change their ways of stuffing token types into that field, but a highlighter that calls another nested highlighter needs to register the nested types for use with token pairs.
2021-06-05Shell: Fix off-by-one error in SyntaxHighlighterMax Wipfli
This changes the Shell syntax highlighter to conform to the now-fixed rendering of syntax highlighting spans in GUI::TextEditor. This also adds some debug output to make debugging easier.
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.
2021-06-01AK+Everywhere: Fix compiletime format parsing of replacement fieldsAli Mohammad Pur
2021-06-01Everywhere: codepoint => code pointAndreas Kling
2021-06-01LibGUI+Shell+bt+ls: Use proper APIs for creating file URLsMax Wipfli
This patch replaces ad-hoc generation of file URL strings with using URL::create_with_file_scheme().
2021-05-29Everywhere: Sort out superfluous QuickSort.h importsBen Wiederhake
They were sorta unneeded. :^)
2021-05-27Shell: Disable the valid test as it has a high failure rate on targetAndrew Kaster
Tracked by #7336
2021-05-24LibLine+Shell: Allow some programs to modify the current termiosAli Mohammad Pur
This setting can be controlled by setting the PROGRAMS_ALLOWED_TO_MODIFY_DEFAULT_TERMIOS _local_ shell variable to a list containing such programs.
2021-05-24AK+Everywhere: Consolidate String::index_of() and String::find()Andreas Kling
We had two functions for doing mostly the same thing. Combine both of them into String::find() and use that everywhere. Also add some tests to cover basic behavior.
2021-05-22Shell: Make sure all tests put their temp dirs in /tmpAndrew Kaster
Follow-on to #7337. Been seeing other CI test failures that point to these temp directories, so let's just move all of them to /tmp. I'm sure someone will write ext2fs stress tests later :^) Example: /usr/Tests/Shell/control-structure-as-command.sh Core::Socket: Failed to connect() to /tmp/portal/inspectables: ... + rm -rf shell-test 2>/dev/null + mkdir shell-test Error: The action has timed out.
2021-05-21Shell: Use /tmp for all file operations valid.sh testAndrew Kaster
Not doing so sometimes intermittently caused the '*' glob expansion test to fail and lock up the shell.
2021-05-21Shell: Hide job times behind SHELL_JOB_DEBUG flagAndrew Kaster
2021-05-19Shell: Avoid moving AK::Function instances while inside themAli Mohammad Pur
2021-05-13Userland: Tighten a *lot* of pledges! :^)Andreas Kling
Since applications using Core::EventLoop no longer need to create a socket in /tmp/rpc/, and also don't need to listen for incoming connections on this socket, we can remove a whole bunch of pledges!
2021-05-13Shell: Fix incorrect fcntl usagesin-ack
FD_CLOEXEC is a file descriptor flag, so one must use F_{G,S}ETFD instead.
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-11LibLine+Shell: Add dirty history flag and use itsin-ack
This patch adds a new flag called history_dirty to Line::Editor that is set when history is added to but written. Applications can leverage this flag to write history only when it changes. This patch adds an example usage of this functionality to Shell, which will now only save the history when it is dirty.
2021-05-11Shell: Add an option to autosave history every N msAli Mohammad Pur
...and set it to 10 seconds by default.
2021-05-10Shell: Parse '\t' in doublequoted strings as a tab characterAli Mohammad Pur
This not being recognised is surprising.
2021-05-10Shell: Make escaping more intelligentAli Mohammad Pur
Instead of the previous only-escape-with-backslashes, extend the escaping to one of: - No escape - Escape with backslash - Escape with "\xhh" if control character that isn't easily represented as \X - Escape with "\uhhhhhhhh" if unicode character that is too big to represent as "\xhh". Fixes #6986.
2021-05-10Shell: Add support for \uhhhhhhhh escapes in stringsAli Mohammad Pur
This will be replaced with the unicode character whose codepoint is given by the unsigned 32-bit number 'hhhhhhhh' (hex).
2021-05-07Shell: Convert StringBuilder::appendf() => AK::FormatAndreas Kling
2021-05-02Shell: Only match entries from PATH when a program name is givenAli Mohammad Pur
This commit makes the shell: - highlight executables in the current directory as invalid, unless an explicit `./' is given (so, `./foo` isn't red, but `foo` is) - not suggest executables in the current directory unless explicitly requested (by prepending `./`) - not attempt to run an executable in the current directory that has been invoked as a program name and failed execvp(). Note that `./foo` is still executed because it's not invoked as a name, but rather as a path. Fixes the other half of #6774.
2021-05-02Shell: Replace fprintf(stderr) => warnln()Ali Mohammad Pur
2021-05-02Shell: Update shebang handling logicAli Mohammad Pur
This bit of code was kept unmodified since it was first implemented, and I'm not entirely convinced that it ever actually worked :P This commit updates the code to use "modern" classes and constructs, and fixes an issue where the shebang would still contain the '#!' when it was passed to execvp(). Fixes #6774.
2021-05-01Shell: Move the heredocs vector to a local value before processing itAli Mohammad Pur
Otherwise we would end up trying to parse the same heredoc entry, if it contained a sequence terminated by a newline. e.g. `<<-x\n$({` would attempt to read a heredoc entry after `x`, and then after `{` while inside the first heredoc entry. To make this work, we can simply empty the instance vector and keep the state on the stack. Issue found through oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33852
2021-05-01Shell: Make set_is_syntax_error() also copy the error locationAli Mohammad Pur
2021-05-01Shell: Disallow non-bareword nodes as part of a heredoc keyAli Mohammad Pur
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33854
2021-04-29Shell: Implement formatting for HeredocsAli Mohammad Pur
2021-04-29Shell: Add some tests for heredocsAli Mohammad Pur
2021-04-29Shell: Add support for heredocsAli Mohammad Pur
Closes #4283. Heredocs are implemented in a way that makes them feel more like a string (and not a weird redirection, a la bash). There are two tunables, whether the string is dedented (`<<-` vs `<<~`) and whether it allows interpolation (quoted key vs not). To the familiar people, this is how Ruby handles them, and I feel is the most elegant heredoc syntax. Unlike the oddjob that is bash, heredocs are treated exactly as normal strings, and can be used _anywhere_ where a string can be used. They are *required* to appear in the same order as used after a newline is seen when parsing the sequence that the heredoc is used in. For instance: ```sh echo <<-doc1 <<-doc2 | blah blah contents for doc1 doc1 contents for doc2 doc2 ``` The typical nice errors are also implemented :^)
2021-04-29Shell: Do not assume that all parts of a node are enclosed in the nodeAli Mohammad Pur
For instance, heredocs are made of two parts, and the second part is not within the bounds of the first one.
2021-04-29Shell: Avoid position push/pop when checking for next_is()Ali Mohammad Pur
This operation is not a rule and cannot produce nodes.
2021-04-29Shell: Allow Syntax errors to be mutated while parsingAli Mohammad Pur
Some nodes (such as heredocs) cannot be validated immediately, so the entire tree will need to be revalidated if we don't allow mutating syntax errors.
2021-04-29Everywhere: Use "the SerenityOS developers." in copyright headersLinus Groh
We had some inconsistencies before: - Sometimes "The", sometimes "the" - Sometimes trailing ".", sometimes no trailing "." I picked the most common one (lowecase "the", trailing ".") and applied it to all copyright headers. By using the exact same string everywhere we can ensure nothing gets missed during a global search (and replace), and that these inconsistencies are not spread any further (as copyright headers are commonly copied to new files).
2021-04-25Everywhere: Remove empty line after function body opening curly braceLinus Groh
2021-04-23Shell: Add a 'kill' builtin that wraps the system's ownAli Mohammad Pur
Fixes #6578.
2021-04-23Shell: Add support for jobspecs in fg/bg/disown/waitAli Mohammad Pur
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-23Shell: Fix how cd handles the path argumentGunnar Beutner
Previously this didn't work: $ cd -- /usr Invalid path '--' This path fixes this issue and removes the unnecessary else branch because we're already using realpath() later on to resolve relative paths.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-21Shell: Convert String::format() => String::formatted()Andreas Kling
2021-04-20Shell: Auto-completion shouldn't suggest non-executable files for the ↵Gunnar Beutner
program name