mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:35:07 +00:00
Shell: Ignore '\\\n' in input
This allows the user to break a line: ```sh $ echo \ foo ``` is the same as ```sh $ echo foo ```
This commit is contained in:
parent
d64e00a5f6
commit
6e6be8e56e
1 changed files with 9 additions and 1 deletions
|
@ -35,13 +35,21 @@ char Parser::peek()
|
|||
return 0;
|
||||
|
||||
ASSERT(m_offset < m_input.length());
|
||||
return m_input[m_offset];
|
||||
|
||||
auto ch = m_input[m_offset];
|
||||
if (ch == '\\' && m_input.length() > m_offset + 1 && m_input[m_offset + 1] == '\n') {
|
||||
m_offset += 2;
|
||||
return peek();
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
char Parser::consume()
|
||||
{
|
||||
auto ch = peek();
|
||||
++m_offset;
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue