Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -447,7 +447,12 @@ public void Start(Runspace runspace)
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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down