mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
Shell: Recognise the (seemingly) bash-specific <<\WORD heredoc key
Bash eats the backslash in this format (similarly for W\ORD etc.). Dr.POSIX doesn't specify this anywhere, but it's used all over the place, so let's support it.
This commit is contained in:
parent
21ea9cedff
commit
9e978c6cd1
Notes:
sideshowbarker
2024-07-17 00:23:42 +09:00
Author: https://github.com/alimpfard
Commit: 9e978c6cd1
Pull-request: https://github.com/SerenityOS/serenity/pull/21173
Reviewed-by: https://github.com/gmta ✅
1 changed files with 4 additions and 1 deletions
|
@ -168,7 +168,8 @@ Lexer::HeredocKeyResult Lexer::process_heredoc_key(Token const& token)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
if (escaped) {
|
||||
// NOTE: bash eats the backslash outside quotes :shrug:
|
||||
if (escaped && parse_state.last() != Free) {
|
||||
builder.append('\\');
|
||||
escaped = false;
|
||||
}
|
||||
|
@ -568,6 +569,8 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_start()
|
|||
|
||||
auto contents = m_lexer.input().substring_view(start_index, end_index.value_or(m_lexer.tell()) - start_index);
|
||||
reconsume(contents);
|
||||
if (end_index.has_value())
|
||||
reconsume(m_lexer.input().substring_view_starting_after_substring(contents).substring_view(0, m_lexer.tell() - *end_index));
|
||||
|
||||
m_state.buffer.clear();
|
||||
m_state.buffer.append(contents);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue