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

Complex shell quote escaping fails #39

Closed
bricoletc opened this issue Mar 7, 2021 · 0 comments
Closed

Complex shell quote escaping fails #39

bricoletc opened this issue Mar 7, 2021 · 0 comments

Comments

@bricoletc
Copy link
Contributor

bricoletc commented Mar 7, 2021

Hello,

I was trying to instruct snakemake to ignore a specific lsf host which is faulty, so wrote this in my lsf.yaml:

__default__:
  - "-R \"select[hname!='hl-codon-32-02']\""

(This gets parsed as {'__default__': ['-R "select[hname!=\'hl-codon-32-02\']"']} by pyyaml)

The reason I do this is that if the hostname to ignore has special characters, the shell command needs to look like -R "select[hname!='hname']" (see IBM docs : If you need to include a hyphen (-) or other non-alphabetic characters within the string, enclose the text in single quotation marks, for example, bsub -R "select[hname!='host06-x12']")

However this gets passed at submission time as -R select[hname!='hl-codon-32-02'] but lsf cannot submit that (try bsub -Is -R select[hname!='hl-codon-32-02'] bash for eg)

Pfew- long story short, I have found a simple solution to this, and putting in a PR with unit tests.

bricoletc added a commit to bricoletc/lsf that referenced this issue Mar 7, 2021
* The split argument string needs to be rejoined using `shlex`
* Two unit tests for `lsf_config.py` to ensure quotes are shell-escaped
* One modified unit test for `lsf_submit.py` to ensure quotes are
shell-escaped
* Rewrote `__init__` of `Config` object, to directly concatenate
parameter lists. Makes downstream argument string production simpler to
read.
* Added function docstrings in `lsf_config.py` to make understanding easier
bricoletc added a commit to bricoletc/lsf that referenced this issue Mar 7, 2021
* Add vim and ven to gitignore
* Add Snakemake-Profiles#39 solving to changelog
* Add example of complex quote escaping in readme
bricoletc added a commit to bricoletc/lsf that referenced this issue Mar 7, 2021
* Add vim and ven to gitignore
* Add Snakemake-Profiles#39 solving to changelog
* Add example of complex quote escaping in readme
mbhall88 pushed a commit that referenced this issue Mar 12, 2021
* The split argument string needs to be rejoined using `shlex`
* Two unit tests for `lsf_config.py` to ensure quotes are shell-escaped
* One modified unit test for `lsf_submit.py` to ensure quotes are
shell-escaped
* Rewrote `__init__` of `Config` object, to directly concatenate
parameter lists. Makes downstream argument string production simpler to
read.
* Added function docstrings in `lsf_config.py` to make understanding easier
mbhall88 pushed a commit that referenced this issue Mar 12, 2021
* Add vim and ven to gitignore
* Add #39 solving to changelog
* Add example of complex quote escaping in readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants