Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/posix.py @ 24108:d65ecb814fc0 stable
shellquote: fix missing quotes for empty string
"hg kdiff3 -rREV" did not work because 1642eb429536 and 5edb387158a1 failed
to handle empty argument.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 11 Feb 2015 19:57:07 +0900 |
parents | 5edb387158a1 |
children | 609aa973c01d |
comparison
equal
deleted
inserted
replaced
24013:942a5a34b2d0 | 24108:d65ecb814fc0 |
---|---|
320 if os.sys.platform == 'OpenVMS': | 320 if os.sys.platform == 'OpenVMS': |
321 return '"%s"' % s | 321 return '"%s"' % s |
322 global _needsshellquote | 322 global _needsshellquote |
323 if _needsshellquote is None: | 323 if _needsshellquote is None: |
324 _needsshellquote = re.compile(r'[^a-zA-Z0-9._/-]').search | 324 _needsshellquote = re.compile(r'[^a-zA-Z0-9._/-]').search |
325 if not _needsshellquote(s): | 325 if s and not _needsshellquote(s): |
326 # "s" shouldn't have to be quoted | 326 # "s" shouldn't have to be quoted |
327 return s | 327 return s |
328 else: | 328 else: |
329 return "'%s'" % s.replace("'", "'\\''") | 329 return "'%s'" % s.replace("'", "'\\''") |
330 | 330 |