1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

Shell: Treat '(' and '{' as operators in POSIX mode

This commit is contained in:
Ali Mohammad Pur 2023-09-21 02:35:01 +03:30 committed by Jelle Raaijmakers
parent 9e978c6cd1
commit 764ea6104e
3 changed files with 28 additions and 17 deletions

View file

@ -188,7 +188,7 @@ void Parser::handle_heredoc_contents()
ErrorOr<Optional<Token>> Parser::next_expanded_token(Optional<Reduction> starting_reduction)
{
while (m_token_buffer.find_if([](auto& token) { return token.type == Token::Type::Eof; }).is_end()) {
while (m_token_buffer.is_empty() || m_token_buffer.last().type != Token::Type::Eof) {
auto tokens = TRY(m_lexer.batch_next(starting_reduction));
auto expanded = perform_expansions(move(tokens));
m_token_buffer.extend(expanded);
@ -1749,7 +1749,8 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
case '\'':
if (in_quote == Quote::Single) {
in_quote = Quote::None;
TRY(append_string_literal(string.substring_view(*run_start, i - *run_start)));
if (run_start.has_value())
TRY(append_string_literal(string.substring_view(*run_start, i - *run_start)));
run_start = i + 1;
continue;
}