import commands
import optparse
+import shlex
import subprocess
import sys
import os
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
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)