Ali Mohammad Pur
35abbafb7b
Shell: Don't escape display/trailing texts when completing via programs
...
This matches the shell's own behaviour regarding completions.
2024-02-07 00:43:11 +01:00
Ali Mohammad Pur
8666b4fa87
Shell: Provide a valid ending position for POSIX immediate nodes
...
This allows the formatter to generate a correct immediate invocation
without a missing closing brace.
This commit also removes a useless code comment.
2024-02-07 00:43:11 +01:00
Edward Banner
791b0eb709
Shell: Use reverse iterators for history events
...
Replaces the custom find_reverse() function used for searching backwards
through string-based history events with reverse iterators + find_if()
2024-01-23 01:31:25 +03:30
Sam Atkins
8d80841e9c
LibFileSystem+Everywhere: Return ByteString from read_link()
2024-01-16 08:42:34 +00:00
Sam Atkins
56c5ffe398
LibFileSystem+Userland: Return ByteString from real_path()
2024-01-16 08:42:34 +00:00
Dan Klishch
ccd701809f
Everywhere: Add deprecated_ prefix to JsonValue::to_byte_string
...
`JsonValue::to_byte_string` has peculiar type-erasure semantics which is
not usually intended. Unfortunately, it also has a very stereotypical
name which does not warn about unexpected behavior. So let's prefix it
with `deprecated_` to make new code use `as_string` if it just wants to
get string value or `serialized<StringBuilder>` if it needs to do proper
serialization.
2024-01-12 17:41:34 -07:00
Ali Mohammad Pur
da5b1680bb
Shell: Print paths in plain mode when stdout is not a tty
...
This makes e.g. `pwd | ...` behave as expected, where pwd doesn't add a
hyperlink around the path.
2024-01-12 12:47:40 +01:00
Shannon Booth
e2e7c4d574
Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
...
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:
```
Optional<I> opt;
if constexpr (IsSigned<I>)
opt = view.to_int<I>();
else
opt = view.to_uint<I>();
```
For us.
The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Ali Mohammad Pur
5e1499d104
Everywhere: Rename {Deprecated => Byte}String
...
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).
This commit is auto-generated:
$ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
Meta Ports Ladybird Tests Kernel)
$ perl -pie 's/\bDeprecatedString\b/ByteString/g;
s/deprecated_string/byte_string/g' $xs
$ clang-format --style=file -i \
$(git diff --name-only | grep \.cpp\|\.h)
$ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
hanaa12G
19f137c1e6
LibLine: Remove duplicate members in CompletionSuggestion
...
Previously, we stored two representations of the same string in
`CompletionSuggestion` object: one for the bytes and the other for the
code points corresponding to those bytes. To minimize duplication, this
patch combine both representations into a single UTF-8 string, which is
already supported by our new String class.
Following this update, we successfully reduce the size of each object
from 376 bytes to 256 bytes
2023-12-15 16:58:03 +03:30
Andrew Kaster
c145d5410c
Userland: Don't leak objects when constructor arguments throw
...
Similar to d253beb2f7
.
Found with Ali's clang-query script in Shell:
```
for $(find AK Userland -type f -name '*.h' -o -name '*.cpp') {
in_parallel -j 12 -- clang-query -p \
Build/lagom/compile_commands.json $it -c \
'm cxxNewExpr(has(cxxConstructExpr(hasAnyArgument(hasDescendant( \
allOf(isExpandedFromMacro("TRY"), stmtExpr()))))))' \
} | grep -v 'matches.' | tee results
```
2023-12-13 19:21:03 -07:00
Shannon Booth
6ce0d588ee
Everywhere: Avoid calling from_utf8 on FlyString or String
...
We already have a String :^)
2023-12-10 09:45:03 +01:00
Ali Mohammad Pur
fde174645a
Shell: Accept empty set of completions from program completer
...
Falling back to default completions goes directly against the users'
wishes :P
2023-12-01 19:24:57 +03:30
david072
0e1bd54896
Shell/PosixParser: Correctly parse the OR_IF token
...
This fixes an unfortunate typo where we would parse the OR_IF token as
an AST::And node. Now, it is parsed into an AST::Or node :^).
2023-11-20 22:02:30 +03:30
Ali Mohammad Pur
aa73a7c961
Shell: Accept null heredocs in POSIX mode
...
Fixes #21837 .
2023-11-18 16:50:01 +03:30
Ali Mohammad Pur
2eb0a8f3d2
Shell: Expand for loop's iterated expr before iterating over it
...
This only applies to the POSIX mode.
Fixes #21715 .
2023-11-18 16:50:01 +03:30
Ali Mohammad Pur
ad4470bc39
Shell: Escape program-provided completions unless they're marked as code
...
This makes it so program-provided completions don't have to worry about
escaping, making the Shell the only authority on escaping.
2023-11-17 11:02:02 +03:30
Adam Harald Jørgensen
e2f9011a8d
Shell: Improve error propagation
...
This commit replaces 31 release_value_but_fixme_should_propagate_errors
calls with TRYs. :^)
2023-11-14 20:08:27 +03:30
Adam Harald Jørgensen
e89ba794d0
Shell: Include parent and base directories in expanded globs
2023-11-14 20:08:27 +03:30
Adam Harald Jørgensen
cc157629b4
Shell: Expand glob to only directories if it ends with a slash
...
The glob "*/" should only expand to directories, and the directories
should also have a trailing slash. This commit also replaces
Shell::split_path with StringView::split_view since it accomplishes the
same task.
2023-11-14 20:08:27 +03:30
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