Treat Set-Location history paths as literal#27521
Open
KirtiRamchandani wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds coverage and implementation changes so Set-Location -/+ history navigation treats stored paths literally (no wildcard expansion), matching -LiteralPath behavior for history entries that contain wildcard-special characters.
Changes:
- Added a Pester test validating history navigation with wildcard-special characters in the path.
- Updated
SessionStateLocationAPIs.SetLocationto suppress wildcard expansion when navigating location history (-/+) and for-LiteralPath.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 | Adds regression test for history navigation with wildcard-special characters in paths. |
| src/System.Management.Automation/engine/SessionStateLocationAPIs.cs | Suppresses wildcard expansion when applying history undo/redo paths (and when -LiteralPath is used). |
Comment on lines
+324
to
+327
| if (suppressWildcardExpansion) | ||
| { | ||
| context.SuppressWildcardExpansion = true; | ||
| } |
Author
There was a problem hiding this comment.
Addressed in d1f8a3918: context.SuppressWildcardExpansion now preserves an existing true value with |= suppressWildcardExpansion.
a5d3dd3 to
d1f8a39
Compare
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
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.
Summary
Set-Location -/Set-Location +history entries as literal paths after they are read from location historyDetails
PathInfo.Pathvalues stored in the Set-Location history are already resolved paths. When-or+replaced the user input with a history path, the path was still globbed as a normal-Pathvalue, so folder names containing characters like[and]failed to resolve.Fixes #20701
Related #27507
Validation
Start-PSBuild -NoPSModuleRestore -CI -SkipExperimentalFeatureGeneration -UseNuGetOrgreached publish and producedpwsh.exe; the Windows PowerShell-hosted local run failed afterward in post-publish cleanup (Clear-NativeDependenciesparameter binding).Start-PSPester -Path ./test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1 -powershell ./src/powershell-win-core/bin/Debug/net11.0/win7-x64/publish/pwsh.exe -UseNuGetOrg -SkipTestToolBuild -ThrowOnFailurepassed: 22 passed, 0 failed, 2 skipped, 1 pending.