-
Notifications
You must be signed in to change notification settings - Fork 383
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
Decide and document quoting rule #932
Comments
As we're going quite deep in our support for weird (considering interactive shell) I'm not sure how to best write this up rather than to note that quoting needs to be done wherever word splitting can occur (making no assumptions about (On the other hand, would be nice to remove unnecessary quoting where splitting does not occur, for example in assignments and within |
Re that unnecessary quoting, filed mvdan/sh#996 |
I guess I'd be fine with starting to quote all arguments, return values or the RHS of comparisons no matter if they contain variables or not. That'd make it easier to remember, and would colorize consistently in editors. What do you think? |
I agree with it. Actually, I personally prefer quoting them independently of IFS, noglob, etc. in the context. Context-independent constructs are easier to read because we do not need to check the contexts in reading. |
Cool. If you feel like it and can think of a good wording, feel free to take a look at filing a style guide PR. I'll get to it eventually myself, too, no pressure. I think we should follow whatever our tooling (mostly shfmt I guess) does with regards to this, and only apply our "rules" on top of what it does, and not fight the tools. |
Thank you. I think I can try it, but I have questions.
Edit quoting of here strings and shellcheck
It turned out that bash <= 4.3 has a bug: koalaman/shellcheck#1009 (comment), so we should also quote here strings as far as we support bash 4.3. |
Re shfmt, I wonder if that's something we should report as a bug against shfmt. Also, I suppose there's no way to tell shfmt to leave a line alone (e.g. something like Re quote character, I suppose we could write out a preference in the style guide. I've accustomed to using the double quotes by default, excluding sometimes if a constant string needs to embed them. Re control characters, I'm accustomed to using Re |
The text was updated successfully, but these errors were encountered: