Skip to content

Commit e20ce96

Browse files
authored
lit] Update internal shell lexer to remove escape on '$' only for double-quoted strings. (#156742)
PR 156125 removed the escape (backslash) in front of '$' for all quoted strings. It has since been pointed out this should only happen for double-quoted strings. This PR fixes that.
1 parent 5cf9fd0 commit e20ce96

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/utils/lit/lit/ShUtil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def lex_arg_quoted(self, delim):
117117
return str
118118
# LLDB uses "$" at the start of global variable names; it should
119119
# not be escaped nor dropped.
120-
elif c == "\\" and self.look() == "$":
120+
elif c == "\\" and self.look() == "$" and delim == '"':
121121
c = self.eat()
122122
str += c
123123
elif c == "\\" and delim == '"':

llvm/utils/lit/tests/unit/ShUtil.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def test_quoting(self):
3030
self.assertEqual(self.lex(""" a\\ b """, win32Escapes=True), ["a\\", "b"])
3131
self.assertEqual(self.lex('"\\$y = 11"'), ["$y = 11"])
3232
self.assertEqual(self.lex('"expr \\$y = 11"'), ["expr $y = 11"])
33+
self.assertEqual(self.lex("'\\$y = 11'"), ["\\$y = 11"])
34+
self.assertEqual(self.lex("'expr \\$y = 11'"), ["expr \\$y = 11"])
3335

3436
class TestShParse(unittest.TestCase):
3537
def parse(self, str):

0 commit comments

Comments
 (0)