From 09d4d817e6d01ac2caaf44effd2f40829b8ee5cc Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 22 Jul 2016 14:41:14 -0700 Subject: [PATCH] Enable runcmd to use a list for the command, and have it quote elements as needed. --- build.py | 5 ++--- buildtools/config.py | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/build.py b/build.py index 7e86fcb9..3037246e 100755 --- a/build.py +++ b/build.py @@ -232,8 +232,7 @@ def setPythonVersion(args): PYTHON = args[idx+1] del args[idx:idx+2] PYVER = runcmd([PYTHON, '-c', 'import sys; print(sys.version[:3])'], - getOutput=True, echoCmd=True) - msg("PYVER: {!r}".format(PYVER)) + getOutput=True, echoCmd=False) PYSHORTVER = PYVER[0] + PYVER[2] break @@ -283,7 +282,7 @@ def setPythonVersion(args): PYSHORTVER = PYVER[0] + PYVER[2] PYTHON = os.path.abspath(PYTHON) - msg('Build using: "%s"' % PYTHON) + msg('Will build using: "%s"' % PYTHON) msg(runcmd([PYTHON, '-c', 'import sys; print(sys.version)'], True, False)) PYTHON_ARCH = runcmd( diff --git a/buildtools/config.py b/buildtools/config.py index 5df36dcb..560eb607 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -788,16 +788,14 @@ def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True): # add quotes to elements of the command that need it cmd = cmd[:] for idx, item in enumerate(cmd): - if ' ' in item or ';' in item: + if ' ' in item or '\t' in item or ';' in item: if item[0] not in ['"', "'"]: if '"' in item: item = item.replace('"', '\\"') item = '"{}"'.format(item) cmd[idx] = item - + # convert the resulting command to a string cmd = ' '.join(cmd) - #if echoCmd: - # msg(' '.join(cmd)) if echoCmd: msg(cmd)