182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
# OS shell command escaping
#
def quote(ins):
if type(ins) is list:
return " ".join([quote(s) for s in ins])
# Windows: double quotes
elif conf.windows:
return subprocess.list2cmdline([ins])
return '"%s"' % ins
# Posix-style shell quoting
else:
return pipes.quote(ins)
return "%r" % ins
# Convert e.g. "text/x-scpls" MIME types to just "pls" monikers
|
|
>
>
|
>
>
|
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# OS shell command escaping
#
def quote(ins):
if type(ins) is list:
return " ".join([quote(s) for s in ins])
# Windows: double quotes
elif conf.windows:
if re.search(r"""[()<>&%!^'";\s]""", ins):
ins = re.sub(r"([()<>&%^])", "^$1", ins)
ins = ins.replace('"', '\\^"')
return '"%s"' % ins
else:
return subprocess.list2cmdline([ins])
# Posix-style shell quoting
else:
return pipes.quote(ins)
return "%r" % ins
# Convert e.g. "text/x-scpls" MIME types to just "pls" monikers
|