equal
deleted
inserted
replaced
294 if s and not _needsshellquote(s) and not _quotere.search(s): |
294 if s and not _needsshellquote(s) and not _quotere.search(s): |
295 # "s" shouldn't have to be quoted |
295 # "s" shouldn't have to be quoted |
296 return s |
296 return s |
297 return '"%s"' % _quotere.sub(r'\1\1\\\2', s) |
297 return '"%s"' % _quotere.sub(r'\1\1\\\2', s) |
298 |
298 |
|
299 def _unquote(s): |
|
300 if s.startswith(b'"') and s.endswith(b'"'): |
|
301 return s[1:-1] |
|
302 return s |
|
303 |
|
304 def shellsplit(s): |
|
305 """Parse a command string in cmd.exe way (best-effort)""" |
|
306 return pycompat.maplist(_unquote, pycompat.shlexsplit(s, posix=False)) |
|
307 |
299 def quotecommand(cmd): |
308 def quotecommand(cmd): |
300 """Build a command string suitable for os.popen* calls.""" |
309 """Build a command string suitable for os.popen* calls.""" |
301 if sys.version_info < (2, 7, 1): |
310 if sys.version_info < (2, 7, 1): |
302 # Python versions since 2.7.1 do this extra quoting themselves |
311 # Python versions since 2.7.1 do this extra quoting themselves |
303 return '"' + cmd + '"' |
312 return '"' + cmd + '"' |