Commit Graph

12 Commits

Author SHA1 Message Date
Andreas Kling
8c3b603da3 Shell: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
Ali Mohammad Pur
4c40151160 Shell: Implement formatting for Heredocs 2021-04-29 20:25:56 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
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-22 11:22:27 +02:00
AnotherTest
3b8fa5a753 Shell: Add support for indexing into variables
Now a variable may have an optional slice (only _one_ slice), which can
also use negative indices to index from the end.
This works on both lists and strings.
The contents of the slice have the same semantics as brace expansions.
For example:
```sh
$ x=(1 2 3 4 5 6)
$ echo $x[1..3] # select indices 1, 2, 3
2 3 4
$ echo $x[3,4,1,0] # select indices 3, 4, 1, 0 (in that order)
4 5 2 1
$ x="Well Hello Friends!"
$ echo $x[5..9]
Hello
```
2021-03-22 13:15:08 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
AnotherTest
13b65b632a Shell: Add support for enumerating lists in for loops
With some odd syntax to boot:
```sh
$ for index i x in $whatever {}
```
2021-03-07 10:59:51 +01:00
AnotherTest
a45b2ea6fb Shell: Add support for 'immediate' expressions as variable substitutions
This commit adds a few basic variable substitution operations:
- length
    Find the length of a string or a list
- length_across
    Find the lengths of things inside a list
- remove_{suffix,prefix}
    Remove a suffix or a prefix from all the passed values
- regex_replace
    Replace all matches of a given regex with a given template
- split
    Split the given string with the given delimiter (or to its
    code points if the delimiter is empty)
- concat_lists
    concatenates any given lists into one

Closes #4316 (the ancient version of this same feature)
2021-03-07 10:59:51 +01:00
AnotherTest
fec8d7d699 Shell: Corrently indent offset newlines when formatting
Previously, formatting the following would incorrectly skip the indents:
```
{
    foo

    bar
}
```
to create:
```
{

foo

bar
}
```
2021-03-07 10:58:42 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
AnotherTest
2bd77bc93b Shell: Make the parser read consecutive sequences without recursing
This fixes (the easy) part of #4976.
2021-01-23 08:28:58 +01:00
AnotherTest
c1b4e86004 Shell: Add formatter for history events 2021-01-15 19:13:03 +01:00
Andreas Kling
c4e2fd8123 Shell: Move to Userland/Shell/ 2021-01-12 12:04:07 +01:00