##// END OF EJS Templates
Fix util.shellquote on windows.
Alexis S. L. Carvalho -
r4087:587c6c65 default
parent child Browse files
Show More
@@ -798,8 +798,23 b" if os.name == 'nt':"
798 def samestat(s1, s2):
798 def samestat(s1, s2):
799 return False
799 return False
800
800
801 # A sequence of backslashes is special iff it precedes a double quote:
802 # - if there's an even number of backslashes, the double quote is not
803 # quoted (i.e. it ends the quoted region)
804 # - if there's an odd number of backslashes, the double quote is quoted
805 # - in both cases, every pair of backslashes is unquoted into a single
806 # backslash
807 # (See http://msdn2.microsoft.com/en-us/library/a1y7w461.aspx )
808 # So, to quote a string, we must surround it in double quotes, double
809 # the number of backslashes that preceed double quotes and add another
810 # backslash before every double quote (being careful with the double
811 # quote we've appended to the end)
812 _quotere = None
801 def shellquote(s):
813 def shellquote(s):
802 return '"%s"' % s.replace('"', '\\"')
814 global _quotere
815 if _quotere is None:
816 _quotere = re.compile(r'(\\*)("|\\$)')
817 return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
803
818
804 def explain_exit(code):
819 def explain_exit(code):
805 return _("exited with status %d") % code, code
820 return _("exited with status %d") % code, code
General Comments 0
You need to be logged in to leave comments. Login now