mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Make pwsh able to start in a directory with wildcards in the name (#7240)
This commit is contained in:
committed by
Dongbo Wang
parent
5702e3f57a
commit
d61ea03694
@@ -3229,6 +3229,7 @@ namespace System.Management.Automation.Runspaces
|
||||
|
||||
try
|
||||
{
|
||||
providerContext.SuppressWildcardExpansion = true;
|
||||
context.EngineSessionState.SetLocation(Directory.GetCurrentDirectory(), providerContext);
|
||||
}
|
||||
catch (ItemNotFoundException)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user