From 2c2a234c74ce1a5641d3683f6ef947627585b007 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 8 Sep 2011 15:13:05 +0200 Subject: [PATCH] use sh -e instead of shipped shell=true (see included comment) Signed-off-by: Nico Schottelius --- bin/cdist | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bin/cdist b/bin/cdist index 7059f73b..1216edab 100755 --- a/bin/cdist +++ b/bin/cdist @@ -98,13 +98,12 @@ class Cdist: sys.exit(1) def shell_run_or_debug_fail(self, script, *args, **kargs): - kargs['shell'] = True + # Manually execute /bin/sh, because sh -e does what we want + # and sh -c -e does not exit if /bin/false called + args[0].insert(0,"/bin/sh") + args[0].insert(1,"-e") log.debug("Shell exec: " + " ".join(*args)) - # Fail if the script fails - args[0].insert(0,"-e") - print(args) - try: subprocess.check_call(*args, **kargs) except subprocess.CalledProcessError: @@ -115,14 +114,12 @@ class Cdist: self.exit_error("Non-Zero exit code exit of " + " ".join(*args)) def run_or_fail(self, *args, **kargs): - # newargs = ["echo"] - newargs = [] - newargs.extend(*args) + log.debug("Exec: " + " ".join(*args)) try: - subprocess.check_call(newargs, **kargs) + subprocess.check_call(*args, **kargs) except subprocess.CalledProcessError: - self.exit_error("Command failed:", " ".join(newargs)) + self.exit_error("Command failed:", " ".join(*args)) def remote_run_or_fail(self, *args, **kargs): """Run something on the remote side and fail is something breaks"""