When running shell commands, join the command string in the utility function.

This commit is contained in:
Bastian Kleineidam 2010-12-15 20:40:25 +01:00
parent cc0e90648f
commit fbdf2e12e8
7 changed files with 11 additions and 13 deletions

View File

@ -23,8 +23,7 @@ def extract_singlefile_standard (archive, encoding, cmd, **kwargs):
outfile = util.get_single_outfile(kwargs['outdir'], archive)
cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>',
util.shell_quote(outfile)])
# note that for shell calls the command must be a string
return (" ".join(cmdlist), {'shell': True})
return (cmdlist, {'shell': True})
def test_singlefile_standard (archive, encoding, cmd, **kwargs):
@ -44,5 +43,4 @@ def create_singlefile_standard (archive, encoding, cmd, *args, **kwargs):
cmdlist.extend(['-c', '--'])
cmdlist.extend([util.shell_quote(x) for x in args])
cmdlist.extend(['>', util.shell_quote(archive)])
# note that for shell calls the command must be a string
return (" ".join(cmdlist), {'shell': True})
return (cmdlist, {'shell': True})

View File

@ -29,5 +29,4 @@ def create_bzip2 (archive, encoding, cmd, *args, **kwargs):
cmdlist.extend(['-c', '-z', '--'])
cmdlist.extend([util.shell_quote(x) for x in args])
cmdlist.extend(['>', util.shell_quote(archive)])
# note that for shell calls the command must be a string
return (" ".join(cmdlist), {'shell': True})
return (cmdlist, {'shell': True})

View File

@ -25,5 +25,4 @@ def create_compress (archive, encoding, cmd, *args, **kwargs):
cmdlist.append('-c')
cmdlist.extend([util.shell_quote(x) for x in args])
cmdlist.extend(['>', util.shell_quote(archive)])
# note that for shell calls the command must be a string
return (" ".join(cmdlist), {'shell': True})
return (cmdlist, {'shell': True})

View File

@ -25,7 +25,7 @@ def extract_cpio (archive, encoding, cmd, **kwargs):
if kwargs['verbose']:
cmdlist.append('-v')
cmdlist.extend(['<', util.shell_quote(os.path.abspath(archive))])
return (" ".join(cmdlist), {'cwd': kwargs['outdir'], 'shell': True})
return (cmdlist, {'cwd': kwargs['outdir'], 'shell': True})
def list_cpio (archive, encoding, cmd, **kwargs):
@ -50,4 +50,4 @@ def create_cpio(archive, encoding, cmd, *args, **kwargs):
cmdlist[0:0] = findcmd
cmdlist.append('-0')
cmdlist.extend([">", util.shell_quote(archive)])
return (" ".join(cmdlist), {'shell': True})
return (cmdlist, {'shell': True})

View File

@ -30,4 +30,4 @@ def extract_rpm (archive, encoding, cmd, **kwargs):
r'"*\.\.*"']
if kwargs['verbose']:
cmdlist.append('-v')
return (" ".join(cmdlist), {'cwd': kwargs['outdir'], 'shell': True})
return (cmdlist, {'cwd': kwargs['outdir'], 'shell': True})

View File

@ -25,5 +25,4 @@ def extract_compress (archive, encoding, cmd, **kwargs):
outfile = util.get_single_outfile(kwargs['outdir'], archive)
cmdlist.extend(['-c', util.shell_quote(archive), '>',
util.shell_quote(outfile)])
# note that for shell calls the command must be a string
return (" ".join(cmdlist), {'shell': True})
return (cmdlist, {'shell': True})

View File

@ -95,6 +95,9 @@ def run (cmd, **kwargs):
if kwargs:
log_info(" with %s" % ", ".join("%s=%s" % (k, shell_quote(str(v)))\
for k, v in kwargs.items()))
if kwargs.get("shell"):
# for shell calls the command must be a string
cmd = " ".join(cmd)
return subprocess.call(cmd, **kwargs)