1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

Shell: Allow parts of globs to be named in match expressions

This patchset allows a match expression to have a list of names for its
glob parts, which are assigned to the matched values in the body of the
match.
For example,
```sh
stuff=foobarblahblah/target_{1..30}
for $stuff {
    match $it {
        */* as (dir sub) {
            echo "doing things with $sub in $dir"
            make -C $dir $sub # or whatever...
        }
    }
}
```

With this, match expressions are now significantly more powerful!
This commit is contained in:
AnotherTest 2020-10-25 10:42:03 +03:30 committed by Andreas Kling
parent 0801b1fada
commit 1a4ac3531f
6 changed files with 115 additions and 10 deletions

View file

@ -912,6 +912,8 @@ private:
struct MatchEntry {
NonnullRefPtrVector<Node> options;
Optional<Vector<String>> match_names;
Optional<Position> match_as_position;
Vector<Position> pipe_positions;
RefPtr<Node> body;
};