From 719c760f51372b99982e824fd1e4a670eb950861 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Sun, 11 Jul 2010 22:44:38 +1000 Subject: [PATCH] --dump no longer quotes things unless they need to be quoted --- encode.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/encode.py b/encode.py index 28767bf..a6f0cd8 100755 --- a/encode.py +++ b/encode.py @@ -2,6 +2,7 @@ import commands import optparse +import shlex import subprocess import sys import os @@ -11,6 +12,14 @@ import shutil class FatalException(Exception): pass +def mkarg(arg): + quoted_arg = commands.mkarg(arg) + arg = quoted_arg[2:-1] + if len(shlex.split(arg)) == 1: + return arg + else: + return quoted_arg[1:] + class Command(object): def __init__(self, profile, opts): self.profile = profile @@ -33,7 +42,7 @@ class Command(object): def do_exec(self, args): if self.opts.dump: - print "".join(map(commands.mkarg, args))[1:] + print " ".join(map(mkarg, args)) else: if subprocess.Popen(args).wait() != 0: raise FatalException("Failure executing command: %s" % args) -- 2.39.2