From 8578537b17de6e4f2c94d864b33b4a0a7ac374f5 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 12 May 2010 21:47:58 +0000 Subject: [PATCH] lit: Fix a sh lexing bug which caused annotate-token.m to fail when run with the internal shell parser; we weren't lexing the quotes in a command like:: clang -DFOO='hello' correctly. llvm-svn: 103652 --- utils/lit/lit/ShUtil.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/lit/lit/ShUtil.py b/utils/lit/lit/ShUtil.py index c8f933245d3..dda622a48a8 100644 --- a/utils/lit/lit/ShUtil.py +++ b/utils/lit/lit/ShUtil.py @@ -67,6 +67,9 @@ class ShLexer: elif c == '"': self.eat() str += self.lex_arg_quoted('"') + elif c == "'": + self.eat() + str += self.lex_arg_quoted("'") elif not self.win32Escapes and c == '\\': # Outside of a string, '\\' escapes everything. self.eat() @@ -287,6 +290,10 @@ class TestShParse(unittest.TestCase): Pipeline([Command(['echo', 'hello'], [])], False)) self.assertEqual(self.parse('echo ""'), Pipeline([Command(['echo', ''], [])], False)) + self.assertEqual(self.parse("""echo -DFOO='a'"""), + Pipeline([Command(['echo', '-DFOO=a'], [])], False)) + self.assertEqual(self.parse('echo -DFOO="a"'), + Pipeline([Command(['echo', '-DFOO=a'], [])], False)) def test_redirection(self): self.assertEqual(self.parse('echo hello > c'),