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

Another option for formatting multi-line shell commands #48

Open
tbooth opened this issue Sep 21, 2023 · 2 comments
Open

Another option for formatting multi-line shell commands #48

tbooth opened this issue Sep 21, 2023 · 2 comments
Labels
reviewer Issues arising from comments on https://github.com/carpentries-lab/reviews/issues/17

Comments

@tbooth
Copy link
Collaborator

tbooth commented Sep 21, 2023

From @jdblischak

I know you recommend using r""" to make the quoting more robust, but personally I find this more readable:

 shell:
        """
        fastqc -o . {input}
        mv {wildcards.sample}_fastqc.html {output.html}
        mv {wildcards.sample}_fastqc.zip  {output.zip}
        """

compared to your recommendation:

shell:
       r"""fastqc -o . {input}
           mv {wildcards.sample}_fastqc.html {output.html}
           mv {wildcards.sample}_fastqc.zip  {output.zip}
        """

Especially since this example doesn't require robust quoting.

@tbooth tbooth added the reviewer Issues arising from comments on https://github.com/carpentries-lab/reviews/issues/17 label Sep 21, 2023
@tbooth
Copy link
Collaborator Author

tbooth commented Sep 21, 2023

I had a look at the standard for docstrings, which are a common Python example of multi-line strings (https://peps.python.org/pep-0257/) but that simply says putting a newline right after the opening quotes is optional. I used the format I tend to use myself with but I guess I'm not really fussed either way.

Regarding when to use robust quoting, my current approach in my real workflows is to use robust quoting consistently for everything, rather then looking at each case and adding the r only when necessary. So I taught it the way I do it. But then you might fairly point out that I'm not using r"..." for regular quotes, so this is inconsistent.

Given that none of the examples in the main workflow rely on the r, perhaps this should be relegated to chapter 13 after all. It does make the code more readable.

@tbooth
Copy link
Collaborator Author

tbooth commented Sep 21, 2023

I've removed mention of r-strings until ep13. Still on the fence about how to place the text within the quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewer Issues arising from comments on https://github.com/carpentries-lab/reviews/issues/17
Projects
None yet
Development

No branches or pull requests

1 participant