-
Notifications
You must be signed in to change notification settings - Fork 257
Escape percentage sign in env variables #264
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
Conversation
|
This topic has been raised before about what escaping, if any to do for environment variables, as there's no way to do it safely and correctly it was decided that we wouldn't implement a half measure. |
|
@leehambley but there is a half measure already: |
|
Indeed, and one special case concession was already the wrong way to fix it. If you can find a way to reliably escape everything that is required under posix and bash's superset of special tokens. gives a good reference, but there is no correct implementation in Ruby that we have found. |
|
Was about to submit my own PR for a similar issue, but noticed this one and thought it would be better to comment here. In I've written a small change which fixes the My thought on why that escaping is okay is that it's not trying to protect the user from the realities of shell interpolation, rather it's making sure valid strings are passed to Let me know what you think! |
I'd tend to agree, but there are no absolutes, and environment variables containing |
|
That's absolutely fair. Do you think there's an argument for failing early by default if any environment variable contains a '%' character in that case, with an option for people to say "I know which shell I'm using, and it'll be okay"? I realise that would be a breaking change, so needs more careful planning, and would take longer to make its way to a release, but it feels like it would be nice to fail early and explicitly where possible. Edit: For my own knowledge, I'm curious which shells have issues with '%'. Was there a discussion somewhere I can read? The behaviour I've seen in $ FOO="asdf%asdf"
$ echo $FOO
asdf%asdf |
|
The only internet based citation I can find is http://stackoverflow.com/a/2821183/119669 - But it's highly possible to misread, even the two quoted paragraphs form the open standards document referenced. I'd be fine, as I said, let me review the change a bit more thoroughly when I have change. |
|
Thanks! Didn't intend to pressure/rush the change at all. Just always keen to improve my knowledge on things. :) |
|
All fine mate, by the way, please update the changelog, etc so I can merge this - |
|
Closing, as we have #280 now |
Before:
ArgumentError: invalid value for Integer(): "/usr/bin/env git fetch origin"if env variable has percentage sign in itNow:
works fine.
I guess inside
withinmethod this issue will still remain if someone will doin: "/usr/i_love_cra%zy_folders", but I assumed that it's rather rare usecase and no-one should have % inside folder names.