Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/shellescape/main.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
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("'", "'\"'\"'") + "'" |