-
Notifications
You must be signed in to change notification settings - Fork 903
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
If the package uses $packageParameters instead of $env:PackageParameters, quotes are removed #406
Comments
Did you read the wiki/ |
It's very specific on how to do this:
|
The above applies to any option, not just install args. |
Yes, I did read this. Did you check the samples I posted? :-) Both of them I have tested and they did not work. |
I did, I believe you are in PowerShell and you need I didn't see it in the sample set. |
It's the very first entry in the list of things I tried :) |
What version of choco? |
v0.9.9.8 |
Can you post a gist of the log file (relevant bits)? |
I'm guessing a bug :) |
Apologies, I've gotten this question about how to pass arguments quite a few times, I default to passing back the wiki article |
Don't worry, I understand that you have to process issues very quickly. Here is the gist: It contains the complete log for the test with In line 129 is the output from my |
You know what - I'm guessing that something in the way this gets passed back to powershell may be doing something weird - look at line 128 https://gist.github.com/dhilgarth/77ce8e452d17375a3bc5#file-chocolatey-log-L128 (it's still passed with quotes). |
Yes, that is the reason. I built a batch script to automatically pull down my boxstarter configuration etc. from a private git repository and I went nuts figuring out the quote escaping of the Here is my batch script as an example:
|
It looks like the issue is right here - https://github.com/chocolatey/choco/blob/master/src/chocolatey/infrastructure.app/services/PowershellService.cs#L116-L117. InstallArgs doesn't really suffer because it is also passed as an environment variable and is used later by chocolatey itself. The package itself should probably be using |
@dhilgarth we commented at almost the same time. :) |
I noticed :) I agree, that is where the quote escaping should happen. |
@dhilgarth if you feel comfortable providing a PR, I'd accept escaping quotes as ``"`. |
Not sure that is correct. Would need to test. |
But I dropped the priority since the package isn't following the recommendations of what to use. https://github.com/chocolatey/choco/blob/master/src/chocolatey/infrastructure.app/templates/ChocolateyReadMeTemplate.cs#L92 |
Indeed. I missed that - I just copied the code from somewhere, but I forgot from where. Maybe I simply missed that line that assigned the environment variable to the local variable. |
Looks like the escape needed to be |
When using powershell arguments ( `$packageParameters`) instead of the environment variables (`$env:chocolateyPackageParameters`), be sure that the arguments are able to retain any quotes that are passed in so that the two variables match. Otherwise you get strange behavior. Folks should not really be using the passed in arguments as they are not part of the public API, but that doesn't mean they won't use them.
Rename function to something more readable.
* stable: (GH-338) Specs (GH-338) Remove incompatible attributes in files (GH-338) IFilesService.ensure_compatible_file_attributes (GH-338) IFileSystem enhancements (GH-338) Fix ensure_file_attribute_set (maint) remove debug message (GH-406) rename function (GH-406) Passed powershell args retain quotes
I am trying to pass quoted values to the
-params
switch, but it looks like it is simply not working.In a test package, I am simply outputting
$packageParameters
to see what I get.Here is what I tried:
-params '/licenseName:""Daniel Hilgarth""'
-params '"/licenseName:""Daniel Hilgarth"""'
-params '"/licenseName:"Daniel Hilgarth""'
-params '/licenseName:"Daniel Hilgarth"'
-params "/licenseName:""Daniel Hilgarth"""
Both of them resulted in a
$packageParameters
value fof/licenseName:Daniel Hilgarth
Additionally, I tried these:
-params '"/licenseName:\"Daniel Hilgarth\""'
-> Resulted in the message that choco wants to install two packages:<package-name>;Hilgarth
-params '"/licenseName:
"Daniel Hilgarth""'
-> Result:/licenseName:
Daniel Hilgarth``I have the feeling that this is a bug in chocolatey's parameters parsing
The text was updated successfully, but these errors were encountered: