1
Fork 0
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:
AnotherTest 2020-09-16 05:11:09 +04:30 committed by Andreas Kling
parent d64e00a5f6
commit 6e6be8e56e

View file

@ -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;
}