Only quote commandline arguments that need quoting.
This commit is contained in:
parent
7d39df7748
commit
8cbef81a50
|
@ -19,15 +19,15 @@ from patoolib import util
|
|||
|
||||
def extract_bzip2 (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a BZIP2 archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.extend(['-c', '-d'])
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
cmdlist.extend(['--', archive, '>', outfile])
|
||||
cmdlist.extend(['--', util.shell_quote(archive), '>',
|
||||
util.shell_quote(outfile)])
|
||||
# note that for shell calls the command must be a string
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
||||
|
||||
def test_bzip2 (archive, encoding, cmd, **kwargs):
|
||||
|
@ -41,12 +41,11 @@ def test_bzip2 (archive, encoding, cmd, **kwargs):
|
|||
|
||||
def create_bzip2 (archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a BZIP2 archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.extend(['-c', '-z', '--'])
|
||||
cmdlist.extend(args)
|
||||
cmdlist.extend(['>', archive])
|
||||
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
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
|
@ -19,12 +19,11 @@ from patoolib import util
|
|||
|
||||
def create_compress (archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a compressed archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.append('-c')
|
||||
cmdlist.extend(args)
|
||||
cmdlist.extend(['>', archive])
|
||||
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
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
|
@ -19,14 +19,13 @@ from patoolib import util
|
|||
|
||||
def extract_cpio (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a CPIO archive."""
|
||||
cmdlist = [cmd, '--extract', '--make-directories',
|
||||
cmdlist = [util.shell_quote(cmd), '--extract', '--make-directories',
|
||||
'--preserve-modification-time', '--no-absolute-filenames',
|
||||
'--force-local', '--nonmatching', '"*\.\.*"']
|
||||
'--force-local', '--nonmatching', r'"*\.\.*"']
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.extend(['<', os.path.abspath(archive)])
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'cwd': kwargs['outdir'], 'shell': True})
|
||||
cmdlist.extend(['<', util.shell_quote(os.path.abspath(archive))])
|
||||
return (" ".join(cmdlist), {'cwd': kwargs['outdir'], 'shell': True})
|
||||
|
||||
|
||||
def list_cpio (archive, encoding, cmd, **kwargs):
|
||||
|
@ -41,15 +40,14 @@ test_cpio = list_cpio
|
|||
|
||||
def create_cpio(archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a CPIO archive."""
|
||||
cmdlist = [cmd, '--create']
|
||||
cmdlist = [util.shell_quote(cmd), '--create']
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
if len(args) != 0:
|
||||
findcmd = ['find', '-print0']
|
||||
findcmd.extend(args)
|
||||
findcmd.extend([util.shell_quote(x) for x in args])
|
||||
findcmd.append('|')
|
||||
cmdlist[0:0] = findcmd
|
||||
cmdlist.append('-0')
|
||||
cmdlist.extend([">", archive])
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
cmdlist.extend([">", util.shell_quote(archive)])
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
|
@ -19,14 +19,14 @@ from patoolib import util
|
|||
|
||||
def extract_gzip (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a GZIP archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
cmdlist.extend(['-c', '-d', '--', archive, '>', outfile])
|
||||
cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>',
|
||||
util.shell_quote(outfile)])
|
||||
# note that for shell calls the command must be a string
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
||||
extract_compress = extract_gzip
|
||||
|
||||
|
@ -50,13 +50,12 @@ test_compress = test_gzip
|
|||
|
||||
def create_gzip (archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a GZIP archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.append('-c')
|
||||
cmdlist.append('--')
|
||||
cmdlist.extend(args)
|
||||
cmdlist.extend(['>', archive])
|
||||
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
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
|
@ -19,14 +19,14 @@ from patoolib import util
|
|||
|
||||
def extract_lzip (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a LZIP archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
cmdlist.extend(['-c', '-d', '--', archive, '>', outfile])
|
||||
cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>',
|
||||
util.shell_quote(outfile)])
|
||||
# note that for shell calls the command must be a string
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
||||
def test_lzip (archive, encoding, cmd, **kwargs):
|
||||
"""Test a LZIP archive."""
|
||||
|
@ -38,13 +38,12 @@ def test_lzip (archive, encoding, cmd, **kwargs):
|
|||
|
||||
def create_lzip (archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a LZIP archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.append('-c')
|
||||
cmdlist.append('--')
|
||||
cmdlist.extend(args)
|
||||
cmdlist.extend(['>', archive])
|
||||
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
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
|
@ -19,14 +19,14 @@ from patoolib import util
|
|||
|
||||
def extract_lzma (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a LZMA archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
cmdlist.extend(['-c', '-d', '--', archive, '>', outfile])
|
||||
cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>',
|
||||
util.shell_quote(outfile)])
|
||||
# note that for shell calls the command must be a string
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
||||
def test_lzma (archive, encoding, cmd, **kwargs):
|
||||
"""Test a LZMA archive."""
|
||||
|
@ -38,13 +38,12 @@ def test_lzma (archive, encoding, cmd, **kwargs):
|
|||
|
||||
def create_lzma (archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a LZMA archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.append('-c')
|
||||
cmdlist.append('--')
|
||||
cmdlist.extend(args)
|
||||
cmdlist.extend(['>', archive])
|
||||
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
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
|
@ -19,14 +19,14 @@ from patoolib import util
|
|||
|
||||
def extract_lzop (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a LZOP archive."""
|
||||
cmdlist = [cmd, '-c', '-d']
|
||||
cmdlist = [util.shell_quote(cmd), '-c', '-d']
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('--verbose')
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
cmdlist.extend(['--', archive, '>', outfile])
|
||||
cmdlist.extend(['--', util.shell_quote(archive), '>',
|
||||
util.shell_quote(outfile)])
|
||||
# note that for shell calls the command must be a string
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
||||
def list_lzop (archive, encoding, cmd, **kwargs):
|
||||
"""List a LZOP archive."""
|
||||
|
|
|
@ -18,16 +18,16 @@ import os
|
|||
from patoolib import util
|
||||
|
||||
def extract_rpm (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a DEB archive."""
|
||||
"""Extract a RPM archive."""
|
||||
# also check cpio
|
||||
cpio = util.find_program("cpio")
|
||||
if not cpio:
|
||||
raise util.PatoolError("cpio(1) is required for rpm2cpio extraction; please install it")
|
||||
cmdlist = [cmd, os.path.abspath(archive), "|", cpio, '--extract',
|
||||
'--make-directories', '--preserve-modification-time',
|
||||
path = util.shell_quote(os.path.abspath(archive))
|
||||
cmdlist = [util.shell_quote(cmd), path, "|", util.shell_quote(cpio),
|
||||
'--extract', '--make-directories', '--preserve-modification-time',
|
||||
'--no-absolute-filenames', '--force-local', '--nonmatching',
|
||||
'"*\.\.*"']
|
||||
r'"*\.\.*"']
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'cwd': kwargs['outdir'], 'shell': True})
|
||||
return (" ".join(cmdlist), {'cwd': kwargs['outdir'], 'shell': True})
|
||||
|
|
|
@ -19,11 +19,11 @@ from patoolib import util
|
|||
|
||||
def extract_compress (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a compressed archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
cmdlist.extend(['-c', archive, '>', outfile])
|
||||
cmdlist.extend(['-c', util.shell_quote(archive), '>',
|
||||
util.shell_quote(outfile)])
|
||||
# note that for shell calls the command must be a string
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
|
@ -19,14 +19,14 @@ from patoolib import util
|
|||
|
||||
def extract_xz (archive, encoding, cmd, **kwargs):
|
||||
"""Extract a XZ archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
cmdlist.extend(['-c', '-d', '--', archive, '>', outfile])
|
||||
cmdlist.extend(['-c', '-d', '--', util.shell_quote(archive), '>',
|
||||
util.shell_quote(outfile)])
|
||||
# note that for shell calls the command must be a string
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
||||
def test_xz (archive, encoding, cmd, **kwargs):
|
||||
"""Test a XZ archive."""
|
||||
|
@ -38,13 +38,12 @@ def test_xz (archive, encoding, cmd, **kwargs):
|
|||
|
||||
def create_xz (archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a XZ archive."""
|
||||
cmdlist = [cmd]
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('-v')
|
||||
cmdlist.append('-c')
|
||||
cmdlist.append('--')
|
||||
cmdlist.extend(args)
|
||||
cmdlist.extend(['>', archive])
|
||||
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
|
||||
cmd = " ".join([util.shell_quote(x) for x in cmdlist])
|
||||
return (cmd, {'shell': True})
|
||||
return (" ".join(cmdlist), {'shell': True})
|
||||
|
|
Loading…
Reference in New Issue