blob: 857bb208780fe22d7c8dc6e9a90caba97eaa35e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# Copyright 2016 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
import re
import shlex
# back port from python3
_find_unsafe = re.compile(r'[^\w@%+=:,./-]').search
def _shlex_quote(s):
"""Return a shell-escaped version of the string *s*."""
if not s:
return "''"
if _find_unsafe(s) is None:
return s
# use single quotes, and put single quotes into double quotes
# the string $'b is then quoted as '$'"'"'b'
return "'" + s.replace("'", "'\"'\"'") + "'"
if not hasattr(shlex, 'quote'):
quote = _shlex_quote
else:
quote = shlex.quote
split = shlex.split
|