From 97901d89d9c8c14f0bb359f3df269fa3fe23f35c Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 5 Apr 2010 08:46:09 +0200 Subject: [PATCH] Correct argument quoting for Windows platforms. --- patoolib/util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/patoolib/util.py b/patoolib/util.py index ae61514..99387ac 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -272,9 +272,19 @@ def tmpfile (dir=None, prefix="temp", suffix=None): def shell_quote (value): """Quote all shell metacharacters in given string value with strong (ie. single) quotes, handling the single quote especially.""" + if os.name == 'nt': + return shell_quote_nt(value) return "'%s'" % value.replace("'", r"'\''") +def shell_quote_nt (value): + """Quote argument for Windows system. Modeled after distutils + _nt_quote_args() function.""" + if " " in value: + return '"%s"' % value + return value + + def stripext (filename): """Return the basename without extension of given filename.""" return os.path.splitext(os.path.basename(filename))[0]