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
Protects against spaces in env vars and avoid quoting of all env vars as single entity #1008
Conversation
… as single entity.
Kudos, SonarCloud Quality Gate passed!
|
@@ -792,13 +792,15 @@ def write_jobscript(self, job, jobscript, **kwargs): | |||
use_threads = "--force-use-threads" if not job.is_group() else "" | |||
|
|||
envvars = " ".join( | |||
"{}={}".format(var, os.environ[var]) for var in self.workflow.envvars | |||
# quotes values, as envvars values could have spaces | |||
"{}='{}'".format(var, os.environ[var]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the env var itself contains single quotes? Python provides escape mechanisms that should be used instead: use repr(os.environ[var])
.
) | ||
|
||
exec_job = self.format_job( | ||
self.exec_job, | ||
job, | ||
_quote_all=True, | ||
_quote_all=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this has to be deactivated? It is also needed for other things in the exec job template.
Closing in favor of a global solution in #1491. Nevertheless, thanks a lot for taking a first stab at this! |
Addresses #1007