comparison env/lib/python3.7/site-packages/shellescape/main.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import re
5
6
7 _find_unsafe = re.compile(r'[a-zA-Z0-9_^@%+=:,./-]').search
8
9
10 def quote(s):
11 """Return a shell-escaped version of the string *s*."""
12 if not s:
13 return "''"
14
15 if _find_unsafe(s) is None:
16 return s
17
18 # use single quotes, and put single quotes into double quotes
19 # the string $'b is then quoted as '$'"'"'b'
20
21 return "'" + s.replace("'", "'\"'\"'") + "'"