Fixed #29132: Updated shlex to work better with punctuation chars in POSIX mode.
Thanks to Evan_ for the report and patch.
diff --git a/Lib/shlex.py b/Lib/shlex.py
index e87266f..2c9786c 100644
--- a/Lib/shlex.py
+++ b/Lib/shlex.py
@@ -232,11 +232,6 @@
break # emit current token
else:
continue
- elif self.posix and nextchar in self.quotes:
- self.state = nextchar
- elif self.posix and nextchar in self.escape:
- escapedstate = 'a'
- self.state = nextchar
elif self.state == 'c':
if nextchar in self.punctuation_chars:
self.token += nextchar
@@ -245,6 +240,11 @@
self._pushback_chars.append(nextchar)
self.state = ' '
break
+ elif self.posix and nextchar in self.quotes:
+ self.state = nextchar
+ elif self.posix and nextchar in self.escape:
+ escapedstate = 'a'
+ self.state = nextchar
elif (nextchar in self.wordchars or nextchar in self.quotes
or self.whitespace_split):
self.token += nextchar