1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2026-01-14 19:31:01 +00:00
serenity/Shell
AnotherTest 4c6f7846b4 Shell: Add 'match' expressions
This commit adds an equivalent to the sh 'case' construct, except it's
much more pleasing to look at and write:
```sh
match "$something" {
    p1 { echo "p1!" }
    p2 { echo "p2!" }
    *  { echo "string catch-all!" }
}
```
is the equivalent of:
```sh
case $something in
    p1)
        echo "p1!"
        ;;
    p2)
        echo "p2!"
        ;;
    *)
        echo "catch-all!"
        ;;
esac
```

Since our shell does not treat lists as strings, matching lists is also
possible:

```sh
match (1foo 2foo foo3) {
    (?foo 2* *) { echo wowzers! }
    (* * *) { echo 3-element list catch-all }
}
```
2020-09-15 20:36:59 +02:00
..
Tests Shell: Add some tests for functions 2020-09-14 17:40:18 +02:00
AST.cpp Shell: Add 'match' expressions 2020-09-15 20:36:59 +02:00
AST.h Shell: Add 'match' expressions 2020-09-15 20:36:59 +02:00
Builtin.cpp Shell: Allow redirections and pipes on builtins 2020-08-15 20:48:17 +02:00
CMakeLists.txt Shell: Move printing job status into a Job::print_status() helper 2020-08-06 15:09:49 +02:00
Execution.h Shell: Allow redirections and pipes on builtins 2020-08-15 20:48:17 +02:00
Forward.h Shell: Fix job control and backgrounding 2020-09-09 20:35:21 +02:00
Job.cpp Shell: Fix job control and backgrounding 2020-09-09 20:35:21 +02:00
Job.h Shell: Fix job control and backgrounding 2020-09-09 20:35:21 +02:00
main.cpp Shell: Add support for $0,$1,... 2020-09-14 17:40:18 +02:00
Parser.cpp Shell: Add 'match' expressions 2020-09-15 20:36:59 +02:00
Parser.h Shell: Add 'match' expressions 2020-09-15 20:36:59 +02:00
Shell.cpp Shell: Allow builtins and functions as conditions for 'if' 2020-09-14 17:40:18 +02:00
Shell.h Shell: Add support for functions 2020-09-14 17:40:18 +02:00