소스 검색

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