Make pwsh able to start in a directory with wildcards in the name (#7240)

This commit is contained in:
James Truher [MSFT] 2018-07-12 15:10:31 -07:00 committed by Dongbo Wang
parent 5702e3f57a
commit d61ea03694
2 changed files with 25 additions and 0 deletions

View file

@ -3229,6 +3229,7 @@ namespace System.Management.Automation.Runspaces
try
{
providerContext.SuppressWildcardExpansion = true;
context.EngineSessionState.SetLocation(Directory.GetCurrentDirectory(), providerContext);
}
catch (ItemNotFoundException)

View file

@ -683,3 +683,27 @@ Describe "Pwsh exe resources tests" -Tag CI {
$psversiontable.os | Should -MatchExactly "$($osversion.Major).$($osversion.Minor)"
}
}
Describe 'Pwsh startup in directories that contain wild cards' -Tag CI {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$dirnames = "[T]est","[Test","T][est","Test"
$testcases = @()
foreach ( $d in $dirnames ) {
$null = New-Item -type Directory -path "${TESTDRIVE}/$d"
$testcases += @{ Dirname = $d }
}
}
It "pwsh can startup in a directory named <dirname>" -testcases $testcases {
param ( $dirname )
try {
Push-Location -LiteralPath "${TESTDRIVE}/${dirname}"
$result = & $powershell -c '(Get-Item .).Name'
$result | Should -BeExactly $dirname
}
finally {
Pop-Location
}
}
}