mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1499511 - [mozdevice] Support single-quotes in adb command line, r=gbrown.
This commit is contained in:
parent
b2cb203c15
commit
26b400b059
@ -769,18 +769,19 @@ class ADBDevice(ADBCommand):
|
||||
"""Utility function to return escaped and quoted version of command
|
||||
line.
|
||||
"""
|
||||
re_quotable_chars = re.compile(r"[ ()\"&'\]]")
|
||||
|
||||
def is_quoted(s, delim):
|
||||
if not s:
|
||||
return False
|
||||
return s[0] == delim and s[-1] == delim
|
||||
|
||||
quoted_cmd = []
|
||||
|
||||
for arg in cmd:
|
||||
arg.replace('&', r'\&')
|
||||
|
||||
needs_quoting = False
|
||||
for char in [' ', '(', ')', '"', '&']:
|
||||
if arg.find(char) >= 0:
|
||||
needs_quoting = True
|
||||
break
|
||||
if needs_quoting:
|
||||
arg = "'%s'" % arg
|
||||
if not is_quoted(arg, "'") and not is_quoted(arg, '"') and \
|
||||
re_quotable_chars.search(arg):
|
||||
arg = '"%s"' % arg.replace(r'"', r'\"')
|
||||
|
||||
quoted_cmd.append(arg)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user