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

Shell: Add support for brace expansions

This adds support for (basic) brace expansions with the following
syntaxes:
- `{expr?,expr?,expr?,...}` which is directly equivalent to `(expr expr
  expr ...)`, with the missing expressions replaced with an empty string
  literal.
- `{expr..expr}` which is a new range expansion, with two modes:
    - if both expressions are one unicode code point long, the range is
      equivalent to the two code points and all code points between the
      two (numerically).
    - if both expressions are numeric, the range is equivalent to both
      numbers, and all numbers between the two.
    - otherwise, it is equivalent to `(expr expr)`.

Closes #3832.
This commit is contained in:
AnotherTest 2020-10-24 18:13:02 +03:30 committed by Andreas Kling
parent 567f2f3548
commit 5640e1bc3a
9 changed files with 374 additions and 3 deletions

View file

@ -37,6 +37,7 @@ public:
virtual void visit(const AST::ListConcatenate*);
virtual void visit(const AST::Background*);
virtual void visit(const AST::BarewordLiteral*);
virtual void visit(const AST::BraceExpansion*);
virtual void visit(const AST::CastToCommand*);
virtual void visit(const AST::CastToList*);
virtual void visit(const AST::CloseFdRedirection*);
@ -54,6 +55,7 @@ public:
virtual void visit(const AST::MatchExpr*);
virtual void visit(const AST::Or*);
virtual void visit(const AST::Pipe*);
virtual void visit(const AST::Range*);
virtual void visit(const AST::ReadRedirection*);
virtual void visit(const AST::ReadWriteRedirection*);
virtual void visit(const AST::Sequence*);