Skip to content

Commit

Permalink
Take out shebang from shell definition and add it when script is writ…
Browse files Browse the repository at this point in the history
…ten. (#181)

* Take out shebang from shell definiton and at it when script is written.

* Include shebang in cmd and fix format of string written to file.
  • Loading branch information
koning authored and FrankD412 committed Apr 18, 2019
1 parent 36291d6 commit cc5278d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions maestrowf/interfaces/script/localscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, **kwargs):
"""
super(LocalScriptAdapter, self).__init__()

self._exec = kwargs.pop("shell", "#!/bin/bash")
self._exec = kwargs.pop("shell", "/bin/bash")

def _write_script(self, ws_path, step):
"""
Expand All @@ -82,18 +82,14 @@ def _write_script(self, ws_path, step):
fname = "{}.sh".format(step.name)
script_path = os.path.join(ws_path, fname)
with open(script_path, "w") as script:
script.write(self._exec)
_ = "\n\n{}\n".format(cmd)
script.write(_)
script.write("#!{0}\n\n{1}\n".format(self._exec, cmd))

if restart:
rname = "{}.restart.sh".format(step.name)
restart_path = os.path.join(ws_path, rname)

with open(restart_path, "w") as script:
script.write(self._exec)
_ = "\n\n{}\n".format(restart)
script.write(_)
script.write("#!{0}\n\n{1}\n".format(self._exec, restart))
else:
restart_path = None

Expand Down

0 comments on commit cc5278d

Please sign in to comment.