Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take out shebang from shell definition and add it when script is written. #181

Merged
merged 3 commits into from
Apr 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions maestrowf/interfaces/script/localscriptadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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 Down Expand Up @@ -89,7 +89,7 @@ def _write_script(self, ws_path, step):
restart_path = os.path.join(ws_path, rname)

with open(restart_path, "w") as script:
script.write(self._exec)
script.write("#!"+self._exec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, probably a little bit of a knit pick but I suggest the following:

script.write("#!{}".format(self._exec))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I take that back. Probably the best way to handle it is:

_ = "#!{}\n\n{}\n".format(self._exec, restart)

That gets rid of the excess write in the process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I changed it to this though:

"#!{0}\n\n{1}\n".format(self._exec, cmd)
and
"#!{0}\n\n{1}\n".format(self._exec, restart)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine -- in this case there's no need to be explicit, but it doesn't hurt anything.

Thanks for updating it.

_ = "\n\n{}\n".format(restart)
script.write(_)
else:
Expand Down