Преглед изворни кода

Shell: Ignore '\\\n' in input

This allows the user to break a line:
```sh
$ echo \
   foo
```
is the same as
```sh
$ echo    foo
```
AnotherTest пре 4 година
родитељ
комит
6e6be8e56e
1 измењених фајлова са 9 додато и 1 уклоњено
  1. 9 1
      Shell/Parser.cpp

+ 9 - 1
Shell/Parser.cpp

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