зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1259382 - Make mozbuild.shellutil.quote more useful for e.g. creating printable command lines. r=ted
This commit is contained in:
Родитель
317b423cfb
Коммит
6684d3c1ee
|
@ -143,7 +143,7 @@ def add_old_configure_assignment(var, value_func):
|
|||
assignments.append('%s=' % var)
|
||||
else:
|
||||
if isinstance(value, (list, tuple)):
|
||||
value = ' '.join(quote(v) for v in value)
|
||||
value = quote(*value)
|
||||
assignments.append('%s=%s' % (var, quote(value)))
|
||||
|
||||
@template
|
||||
|
|
|
@ -396,7 +396,7 @@ def old_configure(prepare_configure, extra_old_configure_args, all_options,
|
|||
cmd += extra_old_configure_args
|
||||
|
||||
# For debugging purpose, in case it's not what we'd expect.
|
||||
log.debug('Running %s', ' '.join(quote(a) for a in cmd))
|
||||
log.debug('Running %s', quote(*cmd))
|
||||
|
||||
# Our logging goes to config.log, the same file old.configure uses.
|
||||
# We can't share the handle on the file, so close it. We assume nothing
|
||||
|
|
|
@ -173,7 +173,7 @@ def split(cline):
|
|||
return _ClineSplitter(s).result
|
||||
|
||||
|
||||
def quote(s):
|
||||
def _quote(s):
|
||||
'''Given a string, returns a version that can be used literally on a shell
|
||||
command line, enclosing it with single quotes if necessary.
|
||||
|
||||
|
@ -194,4 +194,16 @@ def quote(s):
|
|||
return t("'%s'") % s.replace(t("'"), t("'\\''"))
|
||||
|
||||
|
||||
def quote(*strings):
|
||||
'''Given one or more strings, returns a quoted string that can be used
|
||||
literally on a shell command line.
|
||||
|
||||
>>> quote('a', 'b')
|
||||
"a b"
|
||||
>>> quote('a b', 'c')
|
||||
"'a b' c"
|
||||
'''
|
||||
return ' '.join(_quote(s) for s in strings)
|
||||
|
||||
|
||||
__all__ = ['MetaCharacterException', 'split', 'quote']
|
||||
|
|
Загрузка…
Ссылка в новой задаче