Commit Graph

355 Commits

Author SHA1 Message Date
hanaa12G
e6c363ac63 Shell: Allow to parse command interactively when hitting Enter key 2023-11-11 14:44:10 +03:30
Tim Schumacher
a2f60911fe AK: Rename GenericTraits to DefaultTraits
This feels like a more fitting name for something that provides the
default values for Traits.
2023-11-09 10:05:51 -05:00
Tim Ledbetter
ff81513634 Shell: Avoid infinite loop when parsing heredoc entry in POSIX mode
Previously, the shell would enter an infinite loop when attempting to
parse a heredoc entry within a `$(` command substitution.
2023-11-08 15:04:08 +03:30
Adam Harald Jørgensen
a1cdfe1b54 Shell: Add support for showing shortened prompt path with ellipsis 2023-11-07 07:46:52 +03:30
Adam Harald Jørgensen
4febd31dba Shell: Shorten prompt path if integer is provided with "\w" option 2023-11-07 07:46:52 +03:30
implicitfield
4b60a99573 Shell: Remove '#' from the list of acceptable bareword characters
This stops the shell from always interpreting '#' as the start of a
comment in non-Posix mode.
2023-10-29 01:35:40 +03:30
Adam Harald Jørgensen
491d61a2fd Shell: Add support for escaping backslash in prompt sequence 2023-10-26 22:33:38 +03:30
Adam Harald Jørgensen
050c73d301 Shell: Add support for showing custom format time in prompt with "\D{}" 2023-10-26 22:33:38 +03:30
Adam Harald Jørgensen
e40955e9c6 Shell: Add support for showing current time in prompt with "\{t|T|@}" 2023-10-26 22:33:38 +03:30
Adam Harald Jørgensen
3d42e68265 Shell: Add support for showing number of jobs in prompt with "\j" 2023-10-26 22:33:38 +03:30
Adam Harald Jørgensen
f81bc8b045 Shell: Add support for showing the history number in prompt with "\!" 2023-10-26 22:33:38 +03:30
Adam Harald Jørgensen
f597d7c730 Shell: Add command to history before running, instead of after 2023-10-26 22:33:38 +03:30
Adam Harald Jørgensen
78b3703586 Shell: Refactor Shell::prompt to use GenericLexer to read the PROMPT var 2023-10-26 22:33:38 +03:30
Ali Mohammad Pur
cc43a7ecda Shell: Add a 'in_parallel' builtin for easy concurrency 2023-10-26 11:15:57 +02:00
implicitfield
2745b48e16 Shell: Don't try to cast NonnullRefPtrs when priting debug output
Fixes a regression from 8a48246e.
2023-10-22 02:02:35 +03:30
Ali Mohammad Pur
a8c7448ccb Shell: Implement the return POSIX builtin
This is also available in the regular shell mode, as it's a generally
useful builtin to have.
2023-10-17 11:02:48 -06:00
Ali Mohammad Pur
2d1c5dbfcb Shell: Allow word-expansion of ${var}, $N, $* and $-
Fixes #21463.
2023-10-17 11:02:48 -06:00
Ali Mohammad Pur
91bb3af505 Shell: Implement the '$*' special variable in the POSIX parser
Fixes #21421.
2023-10-16 19:11:37 +03:30
Ali Mohammad Pur
5cb994d4dd Shell: Minimally implement the 'set' builtin
This only implements the printing and argv setting behaviours.
2023-10-16 19:11:37 +03:30
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Ali Mohammad Pur
dc495e299e Shell: Add support for the bashy list literals in POSIX mode
This is currently only allowed in assignments, where x=(...) is parsed
as the assignment of the list (...) to the variable x.
2023-10-07 22:16:35 +03:30
Ali Mohammad Pur
986130d9ea Shell: Accept IoNumber as a valid redirection target 2023-10-02 21:21:38 +02:00
Ali Mohammad Pur
0214e9b905 Shell: Rewrite 'FOR NAME do ... done' according to Dr.POSIX
Dr.POSIX says this form of the loop is supposed to iterate over exactly
`"$@"`, this commit makes us support that.
2023-10-02 21:21:38 +02:00
Ali Mohammad Pur
764ea6104e Shell: Treat '(' and '{' as operators in POSIX mode 2023-10-02 21:21:38 +02:00
Ali Mohammad Pur
9e978c6cd1 Shell: Recognise the (seemingly) bash-specific <<\WORD heredoc key
Bash eats the backslash in this format (similarly for W\ORD etc.).
Dr.POSIX doesn't specify this anywhere, but it's used all over the
place, so let's support it.
2023-10-02 21:21:38 +02:00
Ali Mohammad Pur
21ea9cedff Shell: Add the POSIX-only 'eval' builtin
This just concatenates its arguments together, and executes it as a
command.
2023-10-02 21:21:38 +02:00
Ali Mohammad Pur
e2af20a69b Shell: Correct the continue builtin's count guard
This builtin only supports count = 1 (as the error message says), but we
were looking for count = 0.
2023-10-02 21:21:38 +02:00
Ali Mohammad Pur
84777fbe62 Shell: Allow the user to set the prompt using PROMPT()
This allows the prompt to be dynamically configurable, making it
possible to display various bits of information in the prompt.
2023-09-07 11:52:37 -06:00
Ali Mohammad Pur
33a3f0e134 Shell: Implement close redirections in POSIX mode
Fixes #20631.
2023-08-31 11:02:57 +03:30
Ali Mohammad Pur
ba4db899d4 LibSyntax+Userland: Make LibSyntax not depend on LibGUI
This moves some stuff around to make LibGUI depend on LibSyntax instead
of the other way around, as not every application that wishes to do
syntax highlighting is necessarily a LibGUI (or even a GUI) application.
2023-08-29 07:57:39 -04:00
Liav A
fb60db7b00 Shell: Add builtin command to reset the internal state
The new builtin command "reset" now resets the entire internal state by
virtually destructing the Shell state and re-constructing it.

This helps for example when setting a new hostname and wanting to view
it in the current Shell program.
2023-08-11 18:48:53 +03:30
Lucas CHOLLET
3f35ffb648 Userland: Prefer _string over _short_string
As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Andreas Kling
34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Andreas Kling
ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
Andreas Kling
26647f2b10 LibCore: Remove the Core::Objects::all_objects() list
Nobody actually used the list of all Core::Objects anyway.
2023-08-06 18:09:25 +02:00
ronak69
1453028975 Shell: Color bareword yellow if it's a prefix of at least one command
Before, if a bareword wasn't a runnable program's filename it got
colored red and white otherwise. Now, additionally it will be checked if
it is a "prefix" of a possible command and colored yellow if it is and
red if not.

Coloring this way provides another "feedback" to the user: If while
typing out a command name the color changes from yellow to red then a
typo occurred :^)

To check if a bareword is a prefix the `Shell::complete_program_name()`
function is utilized (if pressing tab gives you some suggestions then it
is a prefix).
2023-08-04 23:27:59 +03:30
Ali Mohammad Pur
da7bf5f785 Shell: Add support for the '!' POSIX pipeline prefix
This prefix simply inverts the exit code of the pipeline, which we
implement using the 'not' builtin.
2023-08-04 13:28:59 +03:30
Ali Mohammad Pur
b6d7c5fb0e Shell: Correctly track nested expansions in POSIX mode
Previously any expansion closing sequence would've caused the entire
expansion chain to be terminated, fix this by keeping track of active
expansions and running the parser in 'skip' mode.

Fixes #19110.
2023-08-04 13:28:59 +03:30
Shannon Booth
8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Cameron Youell
978fe3c6d5 Shell: Add option Produce symbolic output to umask
Its a standard posix option thats always nice to have :^)
2023-07-02 11:19:10 -06:00
Ali Mohammad Pur
1c1aa2c0d0 Shell: Handle (most) errors in the parsers
This turns all errors into either "OOM" or a proper shell error (if
propagation is impossible or meaningless).
Fixes `echo -en '\xfe\x4a' | $SHELL` crashing.
2023-07-01 17:01:54 +03:30
Hendiadyoin1
3d83d70cac Shell: Stop lying about string types 2023-06-13 01:49:02 +02:00
Ali Mohammad Pur
1696411f66 Shell: Reset the custom Shell keybinds before calling Editor::get_line()
Fixes #19301.
2023-06-12 10:44:44 +03:30
Ben Wiederhake
f20d04726a LibFileSystem+Everything: Remove resolve_executable_from_environment 2023-06-06 23:46:36 +02:00
jwijenbergh
9531abcb1a Shell: Add a "." builtin that aliases to "source" in POSIX
This patch adds an alias to the source builtin when an user types ".".
We cannot just add an enumeration entry using __ENUMERATE_SHELL_BUILTIN
because "." is not a valid name in a function.
This patch adds handling similarly to the name rewriting of ":".

This alias is limited to POSIX mode only.
2023-06-05 09:25:11 +03:30
Ben Wiederhake
365b2bf945 Shell: Prefer File and FileSystem over DeprecatedFile 2023-05-30 00:21:59 +02:00
Ben Wiederhake
0c86ee3876 Shell: Rewrite Shell::possibly_print_error without deprecated API
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-30 00:21:59 +02:00
Ben Wiederhake
8df8f4d75a Shell: Rewrite Shell::runnable_path_for without deprecated API
Also, not allocating a vector for the parts should be a tiny bit more
efficient.
2023-05-30 00:21:59 +02:00
Undefine
0374351595 Shell: Properly detect the kill executable 2023-05-21 14:59:26 +01:00