mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-12-29 04:23:26 +00:00
fix(pwsh): avoid potential deadlock in init (#4335)
This commit is contained in:
parent
1e284347fa
commit
fd5539796f
@ -53,15 +53,21 @@ $null = New-Module starship {
|
||||
}
|
||||
$process = [System.Diagnostics.Process]::Start($startInfo)
|
||||
|
||||
# Read the output and error streams asynchronously
|
||||
# Avoids potential deadlocks when the child process fills one of the buffers
|
||||
# https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput?view=net-6.0#remarks
|
||||
$stdout = $process.StandardOutput.ReadToEndAsync()
|
||||
$stderr = $process.StandardError.ReadToEndAsync()
|
||||
[System.Threading.Tasks.Task]::WaitAll(@($stdout, $stderr))
|
||||
|
||||
# stderr isn't displayed with this style of invocation
|
||||
# Manually write it to console
|
||||
$stderr = $process.StandardError.ReadToEnd().Trim()
|
||||
if ($stderr -ne '') {
|
||||
if ($stderr.Result.Trim() -ne '') {
|
||||
# Write-Error doesn't work here
|
||||
$host.ui.WriteErrorLine($stderr)
|
||||
}
|
||||
|
||||
$process.StandardOutput.ReadToEnd();
|
||||
$stdout.Result;
|
||||
}
|
||||
|
||||
function Enable-TransientPrompt {
|
||||
|
Loading…
Reference in New Issue
Block a user