mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix path handling bug in PSTask (#12554)
This commit is contained in:
@@ -447,7 +447,12 @@ namespace System.Management.Automation.PSTasks
|
||||
try
|
||||
{
|
||||
Runspace.DefaultRunspace = runspace;
|
||||
runspace.ExecutionContext.SessionState.Internal.SetLocation(_currentLocationPath);
|
||||
var context = new CmdletProviderContext(runspace.ExecutionContext)
|
||||
{
|
||||
// _currentLocationPath denotes the current path as-is, and should not be attempted expanded.
|
||||
SuppressWildcardExpansion = true
|
||||
};
|
||||
runspace.ExecutionContext.SessionState.Internal.SetLocation(_currentLocationPath, context);
|
||||
}
|
||||
catch (DriveNotFoundException)
|
||||
{
|
||||
|
||||
+21
@@ -105,6 +105,27 @@ Describe 'ForEach-Object -Parallel Basic Tests' -Tags 'CI' {
|
||||
$parallelScriptLocation.Path | Should -BeExactly $PWD.Path
|
||||
}
|
||||
|
||||
It 'Verifies that the current working directory can have wildcards in its name' {
|
||||
$oldLocation = Get-Location
|
||||
|
||||
$wildcardName = New-Item -Path 'TestDrive:\' -Name '[' -ItemType Directory
|
||||
Set-Location -LiteralPath $wildcardName.FullName
|
||||
try
|
||||
{
|
||||
{ 1..1 | ForEach-Object -Parallel { $PWD } } | Should -Not -Throw
|
||||
|
||||
$wildcardPathResult = 1..1 | ForEach-Object -Parallel { $PWD }
|
||||
$wildcardPathResult.Path | Should -BeExactly $PWD.Path
|
||||
}
|
||||
finally
|
||||
{
|
||||
Set-Location -Path $oldLocation
|
||||
if ($drive -is [System.IO.DirectoryInfo]) {
|
||||
$drive | Remove-Item -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It 'Verifies no terminating error if current working drive is not found' {
|
||||
$oldLocation = Get-Location
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user