mirror of
https://github.com/RGBCube/serenity
synced 2026-01-14 19:31:01 +00:00
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 }
}
```
|
||
|---|---|---|
| .. | ||
| Tests | ||
| AST.cpp | ||
| AST.h | ||
| Builtin.cpp | ||
| CMakeLists.txt | ||
| Execution.h | ||
| Forward.h | ||
| Job.cpp | ||
| Job.h | ||
| main.cpp | ||
| Parser.cpp | ||
| Parser.h | ||
| Shell.cpp | ||
| Shell.h | ||