forked from ungleich-public/cdist
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:
parent
4fd8a16e6c
commit
2c2a234c74
1 changed files with 7 additions and 10 deletions
17
bin/cdist
17
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"""
|
||||
|
|
Loading…
Reference in a new issue