Return a shell-escaped version of the string *s* Unfortunately `shlex.quote` doesn't support Windows, so this method provides that functionality.
(s, platform=None, shell=False)
| 273 | |
| 274 | |
| 275 | def compat_shell_quote(s, platform=None, shell=False): |
| 276 | """Return a shell-escaped version of the string *s* |
| 277 | |
| 278 | Unfortunately `shlex.quote` doesn't support Windows, so this method |
| 279 | provides that functionality. |
| 280 | """ |
| 281 | if platform is None: |
| 282 | platform = sys.platform |
| 283 | |
| 284 | if platform == "win32": |
| 285 | if shell: |
| 286 | return _windows_cmd_shell_quote(s) |
| 287 | return _windows_argv_quote(s) |
| 288 | else: |
| 289 | return shlex.quote(s) |
| 290 | |
| 291 | |
| 292 | def _windows_argv_quote(s): |