Ensure that actually existing paths are processed literally by GameMicrowave · Pull Request #26585 · PowerShell/PowerShell · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f20a9e4
Update DefaultSetDriveFunctionText for literal path
GameMicrowave Dec 8, 2025
18386c5
Suppress wildcard expansion for location history paths
GameMicrowave Dec 8, 2025
788cddf
Add test for Set-Location with wildcard history paths
GameMicrowave Dec 8, 2025
f48fe20
Fix wildcard path handling in Set-Location tests
GameMicrowave Dec 8, 2025
95d4d66
Merge branch 'master' into PathIssue
GameMicrowave Dec 9, 2025
831ee8e
Enhance ResolvePathCommand for literal base path handling
GameMicrowave Dec 10, 2025
da9f51c
Merge branch 'master' into PathIssue
GameMicrowave Dec 11, 2025
97aec45
Update src/Microsoft.PowerShell.Commands.Management/commands/manageme…
GameMicrowave Dec 11, 2025
e5f3a70
Make parameter `-RelativeBasePath` of Resolve-Path command
GameMicrowave Dec 11, 2025
9e30d0c
Enhance Resolve-Path tests for wildcard handling
GameMicrowave Dec 11, 2025
682737b
Add a tab completion test for -RelativeBasePath of Resolve-Path
GameMicrowave Dec 18, 2025
ad9f57e
simplify tab completion code for parameter '-RelativeBasePath' of Res…
GameMicrowave Dec 18, 2025
737426c
Merge branch 'master' into PathIssue
GameMicrowave Dec 18, 2025
2a669b5
Merge branch 'master' into PathIssue
GameMicrowave Jan 14, 2026
99f084e
Merge branch 'master' into PathIssue
GameMicrowave Jan 15, 2026
96e5d50
Merge branch 'master' into PathIssue
GameMicrowave Jan 20, 2026
ac4e049
Merge branch 'master' into PathIssue
GameMicrowave Feb 2, 2026
c3f81f1
Eliminate potential issues in the code
GameMicrowave Feb 8, 2026
0a7ffdb
Merge branch 'master' into PathIssue
GameMicrowave Feb 9, 2026
afddcb4
Merge branch 'master' into PathIssue
GameMicrowave Feb 19, 2026
fa477aa
Merge branch 'master' into PathIssue
GameMicrowave Apr 14, 2026
5caad84
Merge branch 'master' into PathIssue
GameMicrowave Jun 20, 2026
33b0a41
Merge branch 'master' into PathIssue
GameMicrowave Jul 13, 2026
d26bb2e
Merge branch 'master' into PathIssue
GameMicrowave Jul 18, 2026
c36bec9
Potential fix for pull request finding
GameMicrowave Jul 20, 2026
f0e439e
Merge branch 'master' into PathIssue
GameMicrowave Aug 3, 2026
92b3130
Merge branch 'master' into PathIssue
GameMicrowave Aug 8, 2026
9b69e31
Merge branch 'master' into PathIssue
GameMicrowave Oct 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,11 @@ private static void NativeCommandArgumentCompletion(
NativeCompletionSetLocationCommand(context, parameterName, result);
break;
}
case "Resolve-Path" when parameterName.Equals("RelativeBasePath", StringComparison.OrdinalIgnoreCase):
{
NativeCompletionPathArgument(context, "LiteralPath", result);
break;
}
case "Move-Item":
case "Copy-Item":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4889,7 +4889,7 @@ internal static SessionStateAliasEntry[] BuiltInAliases
# .ExternalHelp System.Management.Automation.dll-help.xml
";

internal const string DefaultSetDriveFunctionText = "Set-Location $MyInvocation.MyCommand.Name";
internal const string DefaultSetDriveFunctionText = "Set-Location -LiteralPath $MyInvocation.MyCommand.Name";

internal static readonly ScriptBlock SetDriveScriptBlock = ScriptBlock.CreateDelayParsedScriptBlock(DefaultSetDriveFunctionText, isProductCode: true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ internal PathInfo SetLocation(string path, CmdletProviderContext context, bool l
throw new InvalidOperationException(SessionStateStrings.LocationUndoStackIsEmpty);
}

// Should process history path as literal
context ??= new CmdletProviderContext(this.ExecutionContext);
context.SuppressWildcardExpansion = true;
path = _setLocationHistory.Undo(this.CurrentLocation).Path;
break;
case string originalPathSwitch when !literalPath && originalPathSwitch.Equals("+", StringComparison.Ordinal):
Expand All @@ -261,6 +264,9 @@ internal PathInfo SetLocation(string path, CmdletProviderContext context, bool l
throw new InvalidOperationException(SessionStateStrings.LocationRedoStackIsEmpty);
}

// Should process history path as literal
context ??= new CmdletProviderContext(this.ExecutionContext);
context.SuppressWildcardExpansion = true;
path = _setLocationHistory.Redo(this.CurrentLocation).Path;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,31 @@ Describe "Resolve-Path returns proper path" -Tag "CI" {
(Resolve-Path -Path $Path -RelativeBasePath $BasePath -Force:$Force).Path | Should -BeExactly $ExpectedResult
}
}


Describe "The parameter '-RelativeBasePath' should treat path as literal" -Tags "CI" {
BeforeAll {
$testFolder = 'TestDrive:\[Folder]'
New-Item -ItemType Directory -Path $testFolder
Push-Location -LiteralPath $testFolder
}

It "Should succeed in resolving a path when the relative base path contains a wildcard character" {
(Resolve-Path -LiteralPath . -RelativeBasePath .).Path | Should -Not -BeNullOrEmpty
(Resolve-Path -LiteralPath . -RelativeBasePath . -Relative).Path | Should -Not -BeNullOrEmpty
(Resolve-Path -Path . -RelativeBasePath .).Path | Should -Not -BeNullOrEmpty
(Resolve-Path -Path . -RelativeBasePath . -Relative).Path | Should -Not -BeNullOrEmpty
}

It "Should fill path with literal in tab completion of parameter '-RelativeBasePath'" {
$wildcardNameFile = '[WildcardName].txt'
123 | Out-File -LiteralPath $wildcardNameFile
$completionInfo = TabExpansion2 'Resolve-Path -RelativeBasePath .\'
$completionInfo.CompletionMatches[0].ListItemText | Should -Be $wildcardNameFile
}

AfterAll {
Pop-Location
}
}