Return a shell-escaped version of the string *s*.
(s)
| 323 | _find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.ASCII).search |
| 324 | |
| 325 | def quote(s): |
| 326 | """Return a shell-escaped version of the string *s*.""" |
| 327 | if not s: |
| 328 | return "''" |
| 329 | if _find_unsafe(s) is None: |
| 330 | return s |
| 331 | |
| 332 | # use single quotes, and put single quotes into double quotes |
| 333 | # the string $'b is then quoted as '$'"'"'b' |
| 334 | return "'" + s.replace("'", "'\"'\"'") + "'" |
| 335 | |
| 336 | |
| 337 | def _print_tokens(lexer): |
no test coverage detected