-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Use hard quotes rather than soft quotes #61902 #68435
Conversation
25fecaa
to
8530c76
Compare
rebased with master, so now the automated tests finally succeed. I'm unable to properly test this patch locally myself, because the integrated terminal ends up broken in my build attempts. |
@geirha Thanks for the PR. Two comments:
|
I feel that'll be a messy, half-working solution, where a glob will only work if it happens to not contain space or
I thought about adding a whitelist of characters not needing quoting. but went with trying to make the patch small instead. I can add such a whitelist. |
61f1696
to
05fcf17
Compare
The scope of your PR is to address a problem with env variables #61902, not to fix globbing issues (that are not even mentioned in the original comment). If you want to address globbing issues, please create a separate issue first. |
Fair enough. So I reverted the quote function to its previous state, and introduced a new hardQuote function for the cwd and env vars, including a whitelist to avoid it needlessly quoting words that don't contain any shell metacharacters. |
Thanks for the PR. |
@weinand Ouch. It never occured to me that this could be used with other than bourne-style shells. Especially since the code in question is inside a The hard-quoting might also be wrong then; it's safe for bash, and any other bourne-style shells I know of, but I have no idea if fish has the same quoting rules, nor whether the whitelisted characters are safe to leave unquoted. |
The current code encloses arguments in soft quotes (
"..."
) before injecting them into the shell. Soft quotes prevent some expansions from occuring, but not all. Hard quotes ('...'
) on the other hand, treats everything literally, making it a much safer choice.