fix(pwsh): avoid deadlock in Start-Utf8Process

Resolves #2151
This commit is contained in:
L. Yeung 2022-04-27 02:09:23 +08:00 committed by Jan De Dobbeleer
parent a9671df378
commit 4d048b2658

View file

@ -34,13 +34,15 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
$StartInfo.WorkingDirectory = $PWD.ProviderPath $StartInfo.WorkingDirectory = $PWD.ProviderPath
} }
$StartInfo.CreateNoWindow = $true $StartInfo.CreateNoWindow = $true
$Process.Start() | Out-Null [void]$Process.Start()
$Process.WaitForExit() | Out-Null $stdoutTask = $Process.StandardOutput.ReadToEndAsync()
$stderr = $Process.StandardError.ReadToEnd().Trim() $stderrTask = $Process.StandardError.ReadToEndAsync()
[void]$Process.WaitForExit()
$stderr = $stderrTask.Result.Trim()
if ($stderr -ne '') { if ($stderr -ne '') {
$Host.UI.WriteErrorLine($stderr) $Host.UI.WriteErrorLine($stderr)
} }
return $Process.StandardOutput.ReadToEnd() $stdoutTask.Result
} }
function Set-PoshContext {} function Set-PoshContext {}