diff --git a/patoolib/programs/__init__.py b/patoolib/programs/__init__.py index d03824d..5f14cd0 100644 --- a/patoolib/programs/__init__.py +++ b/patoolib/programs/__init__.py @@ -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}) diff --git a/patoolib/programs/bzip2.py b/patoolib/programs/bzip2.py index 1b61c87..bbeb1ec 100644 --- a/patoolib/programs/bzip2.py +++ b/patoolib/programs/bzip2.py @@ -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}) diff --git a/patoolib/programs/compress.py b/patoolib/programs/compress.py index 8fa0515..5414eaa 100644 --- a/patoolib/programs/compress.py +++ b/patoolib/programs/compress.py @@ -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}) diff --git a/patoolib/programs/cpio.py b/patoolib/programs/cpio.py index 0eb036b..d8a22c3 100644 --- a/patoolib/programs/cpio.py +++ b/patoolib/programs/cpio.py @@ -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}) diff --git a/patoolib/programs/rpm2cpio.py b/patoolib/programs/rpm2cpio.py index 2ff289f..a1eab31 100644 --- a/patoolib/programs/rpm2cpio.py +++ b/patoolib/programs/rpm2cpio.py @@ -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}) diff --git a/patoolib/programs/uncompress.py b/patoolib/programs/uncompress.py index e552f53..3670158 100644 --- a/patoolib/programs/uncompress.py +++ b/patoolib/programs/uncompress.py @@ -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}) diff --git a/patoolib/util.py b/patoolib/util.py index ec113d1..5d152fb 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -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)