Treat Set-Location history paths as literal#27521
Conversation
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). |
| if (suppressWildcardExpansion) | ||
| { | ||
| context.SuppressWildcardExpansion = true; | ||
| } |
There was a problem hiding this comment.
Addressed in d1f8a3918: context.SuppressWildcardExpansion now preserves an existing true value with |= suppressWildcardExpansion.
a5d3dd3 to
d1f8a39
Compare
|
Closing in favor of #27527, which fixes the same Set-Location history wildcard issue by escaping history paths via |
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 -UseNuGetOrgStart-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 -ThrowOnFailureResult: Set-Location.Tests.ps1 passed: 22 passed, 0 failed, 2 skipped, 1 pending.