Bug 1259382 - Make mozbuild.shellutil.quote more useful for e.g. creating printable command lines. r=ted

This commit is contained in:
Mike Hommey 2016-04-05 08:59:46 +09:00
Родитель 317b423cfb
Коммит 6684d3c1ee
3 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -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']