use sh -e instead of shipped shell=true (see included comment)

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-09-08 15:13:05 +02:00
parent 4fd8a16e6c
commit 2c2a234c74

View file

@ -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"""