- Notifications
You must be signed in to change notification settings - Fork8.1k
Quote bare quote file paths if the path includes a double quote character#25631
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
| _=sb.Append('\''); | ||
| quotesAreNeeded=true; | ||
| // Bareword or singlequoted input string. | ||
| if(path[index].IsSingleQuote()) |
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.
It seems the method would be more readable if we ridded ofuseSingleQuoteEscapeRules and replace it withstringType is StringConstantType.SingleQuoted or StringConstantType.BareWord.
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.
That check will change when my PR to keep variables when tab completing paths is merged. If someone is tab completing a bareword string with a variable it needs to use double quote rules.
| $null=New-Item-Path$TestFile1-Force | ||
| $Expected="'$($TestFile1.Insert($TestFile1.LastIndexOf($BadQuote),"'"))'" | ||
| $res= TabExpansion2-inputScript"Get-ChildItem -Path '$TestDrive\" |
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.
If it is intentional to have single quote it is not obvious so please add a comment.
/azp run PowerShell-Windows-Packaging-CI,PowerShell-CI-linux-packaging |
| Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
0380034 intoPowerShell:masterUh oh!
There was an error while loading.Please reload this page.
microsoft-github-policy-servicebot commentedJun 9, 2025 • edited by unfurl-linksbot
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by unfurl-linksbot
Uh oh!
There was an error while loading.Please reload this page.
📣 Hey @@MartinGC94, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗https://aka.ms/PSRepoFeedback |
PR Summary
Fixes the logic for the file path completion so paths with double quote characters get single quotes added just like we do for other problematic characters in bare quote strings.
PR Context
Fixes#25629
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header