Skip to content

Commit 314b1e5

Browse files
author
Nick Yamane
authored
Merge pull request #82 from jbytheway/popen_shell_confusion
Fix popen call to run make
2 parents b151542 + d1fde4f commit 314b1e5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

compiledb/commands/make.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from sys import exit, stdout, stderr
88

99
from compiledb import generate
10-
from compiledb.utils import popen
10+
from compiledb.utils import popen, cmd_join
1111

1212

1313
class AutoconfMockScript:
@@ -92,7 +92,7 @@ def command(ctx, make_cmd, make_args):
9292
cmd = [make_cmd, logging_mode_flags] + list(make_args)
9393
if mock_script.path:
9494
cmd.append("SHELL={}".format(mock_script.path))
95-
pipe = popen(cmd, stdout=PIPE)
95+
pipe = popen(cmd_join(cmd), stdout=PIPE)
9696
options.infile = pipe.stdout
9797
del args['verbose']
9898
done = generate(**args)

compiledb/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ def popen(cmd, encoding='utf-8', **kwargs):
1313

1414
def run_cmd(cmd, encoding='utf-8', **kwargs):
1515
return subprocess.check_output(cmd, **kwargs)
16+
17+
try:
18+
from shlex import quote as cmd_quote
19+
except ImportError:
20+
from pipes import quote as cmd_quote
21+
22+
23+
def cmd_join(cmd):
24+
return ' '.join(cmd_quote(s) for s in cmd)

0 commit comments

Comments
 (0)