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

Protects against spaces in env vars and avoid quoting of all env vars as single entity #1008

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions snakemake/executors/__init__.py
Expand Up @@ -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])
Copy link
Contributor

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]).

for var in self.workflow.envvars
)

exec_job = self.format_job(
self.exec_job,
job,
_quote_all=True,
_quote_all=False,
Copy link
Contributor

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.

use_threads=use_threads,
envvars=envvars,
**kwargs,
Expand Down