1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +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

@ -642,20 +642,6 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_start()
};
}
if (!m_state.escaping && is_part_of_operator(""sv, m_lexer.peek())) {
auto tokens = TRY(Token::maybe_from_state(m_state));
m_state.buffer.clear();
m_state.buffer.append(consume());
m_state.expansions.clear();
m_state.position.start_offset = m_state.position.end_offset;
m_state.position.start_line = m_state.position.end_line;
return ReductionResult {
.tokens = move(tokens),
.next_reduction = Reduction::Operator,
};
}
if (!m_state.escaping && consume_specific('\'')) {
m_state.buffer.append('\'');
return ReductionResult {
@ -708,7 +694,7 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_start()
};
}
if (!m_state.escaping && is_any_of("})"sv)(m_lexer.peek())) {
if (!m_state.escaping && m_state.in_skip_mode && is_any_of("})"sv)(m_lexer.peek())) {
// That's an eof for us.
return ReductionResult {
.tokens = {},
@ -716,6 +702,20 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_start()
};
}
if (!m_state.escaping && is_part_of_operator(""sv, m_lexer.peek())) {
auto tokens = TRY(Token::maybe_from_state(m_state));
m_state.buffer.clear();
m_state.buffer.append(consume());
m_state.expansions.clear();
m_state.position.start_offset = m_state.position.end_offset;
m_state.position.start_line = m_state.position.end_line;
return ReductionResult {
.tokens = move(tokens),
.next_reduction = Reduction::Operator,
};
}
m_state.escaping = false;
m_state.buffer.append(consume());
return ReductionResult {