mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:27:35 +00:00
Shell: Don't skip over the first brace expansion entry if it's empty
Previously we were simply ignoring the empty entry in '{,x}', making it resolve to a list with a single element '(x)', this commit makes that work as expected and resolve to '("" x)'.
This commit is contained in:
parent
7ac8bd44f8
commit
9bf81463f5
1 changed files with 22 additions and 16 deletions
|
@ -1919,6 +1919,12 @@ RefPtr<AST::Node> Parser::parse_brace_expansion_spec()
|
||||||
m_extra_chars_not_allowed_in_barewords.append(',');
|
m_extra_chars_not_allowed_in_barewords.append(',');
|
||||||
|
|
||||||
auto rule_start = push_start();
|
auto rule_start = push_start();
|
||||||
|
NonnullRefPtrVector<AST::Node> subexpressions;
|
||||||
|
|
||||||
|
if (next_is(",")) {
|
||||||
|
// Note that we don't consume the ',' here.
|
||||||
|
subexpressions.append(create<AST::StringLiteral>(""));
|
||||||
|
} else {
|
||||||
auto start_expr = parse_expression();
|
auto start_expr = parse_expression();
|
||||||
if (start_expr) {
|
if (start_expr) {
|
||||||
if (expect("..")) {
|
if (expect("..")) {
|
||||||
|
@ -1933,9 +1939,9 @@ RefPtr<AST::Node> Parser::parse_brace_expansion_spec()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtrVector<AST::Node> subexpressions;
|
|
||||||
if (start_expr)
|
if (start_expr)
|
||||||
subexpressions.append(start_expr.release_nonnull());
|
subexpressions.append(start_expr.release_nonnull());
|
||||||
|
}
|
||||||
|
|
||||||
while (expect(',')) {
|
while (expect(',')) {
|
||||||
auto expr = parse_expression();
|
auto expr = parse_expression();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue