equal
deleted
inserted
replaced
160 # backslash before every double quote (being careful with the double |
160 # backslash before every double quote (being careful with the double |
161 # quote we've appended to the end) |
161 # quote we've appended to the end) |
162 _quotere = None |
162 _quotere = None |
163 _needsshellquote = None |
163 _needsshellquote = None |
164 def shellquote(s): |
164 def shellquote(s): |
|
165 r""" |
|
166 >>> shellquote(r'C:\Users\xyz') |
|
167 '"C:\\Users\\xyz"' |
|
168 >>> shellquote(r'C:\Users\xyz/mixed') |
|
169 '"C:\\Users\\xyz/mixed"' |
|
170 >>> # Would be safe not to quote too, since it is all double backslashes |
|
171 >>> shellquote(r'C:\\Users\\xyz') |
|
172 '"C:\\\\Users\\\\xyz"' |
|
173 >>> # But this must be quoted |
|
174 >>> shellquote(r'C:\\Users\\xyz/abc') |
|
175 '"C:\\\\Users\\\\xyz/abc"' |
|
176 """ |
165 global _quotere |
177 global _quotere |
166 if _quotere is None: |
178 if _quotere is None: |
167 _quotere = re.compile(r'(\\*)("|\\$)') |
179 _quotere = re.compile(r'(\\*)("|\\$)') |
168 global _needsshellquote |
180 global _needsshellquote |
169 if _needsshellquote is None: |
181 if _needsshellquote is None: |