comparison planemo/lib/python3.7/site-packages/shellescape/main.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
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("'", "'\"'\"'") + "'"