comparison env/lib/python3.7/site-packages/shellescape/main.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
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("'", "'\"'\"'") + "'"