-
Notifications
You must be signed in to change notification settings - Fork 930
(#2410) Update arguments utility to handle package parameters starting with dashes #3705
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
Merged
gep13
merged 3 commits into
chocolatey:develop
from
AdmiringWorm:improve-argument-parsing-fix-quotes
Jun 18, 2025
Merged
(#2410) Update arguments utility to handle package parameters starting with dashes #3705
gep13
merged 3 commits into
chocolatey:develop
from
AdmiringWorm:improve-argument-parsing-fix-quotes
Jun 18, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 tasks
81d4af1
to
b92bacf
Compare
gep13
requested changes
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of quick questions/comments, otherwise this looks really good!
…d tests Update EscapePowerShellArguments to also replace single quotes with two single quotes to properly handle parameters containing single quotes. Add Pester tests for 'choco install' and 'choco info' commands to verify correct handling and output of package parameters with single quotes. These changes improve robustness when passing parameters with single quotes to PowerShell scripts and ensure expected behavior is tested. Based on code in PR: chocolatey#2804
…sh syntax Refactor argument splitting logic to correctly handle package arguments that use double-dash prefixes (--). The new SplitOnArguments method handles quoted strings, escaped characters, and nested quotes to ensure accurate parsing of complex argument strings. Add a Pester test to verify upgrading a package with double-dash package parameters works as expected, including environment variable setting and successful upgrade reporting. These changes fix issues with parsing package parameters during upgrades and improve reliability when using advanced argument formats.
…upgrades Add detection of unbalanced single or double quotes in package arguments during install, upgrade, and uninstall commands. Emit warnings to alert users that failures may be related to these potentially problematic arguments. For upgrades and uninstalls, include troubleshooting advice to run `choco info` with local-only flag. Add a test verifying upgrade behavior when package parameters contain single quotes and remembered arguments are enabled, ensuring warnings and diagnostic messages appear as expected. NOTE: Install and uninstall warnings and diagnostics are for future implementations, and will not be shown during normal execution today.
b92bacf
to
f5bf086
Compare
gep13
approved these changes
Jun 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@AdmiringWorm thanks for getting this fixed! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description Of Changes
Motivation and Context
Packages should be possible to install and upgrade even with single quotes being used, and not having an exception about "unterminated single quotes" being thrown.
Testing
useRememberedArgumentsForUpgrades
usingchoco feature enable -n useRememberedArgumentsForUpgrades
.choco install test-params --package-parameters="/Comment:It's great! /SubmittedBy:Someone"
."WARNING: - Comment = It's great!
.choco info test-params --local-only
.choco install test-environment --package-parameters="'--quiet --norestart --wait --includeRecommended --includeOptional'" --verbose --version 0.9
.choco info test-environment --local-only
(to partial package-parameter lines)choco upgrade test-environment
.chocolateyPackageParameters=--quiet --norestart --wait --includeRecommended --includeOptional
Operating Systems Testing
Change Types Made
Change Checklist
Related Issue
choco upgrade
command fails with error messageThe string is missing the terminator: '.
whenuseRememberedArgumentsForUpgrades
feature is enabled #2410