From a24e843ee09ea021a09ce4249081407bb4d59756 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Sat, 13 Feb 2021 19:31:54 +0100 Subject: [PATCH] fix(init): make log messages on pwsh visible again (#2295) --- src/init/starship.ps1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/init/starship.ps1 b/src/init/starship.ps1 index fd1604609..e5a1fb148 100644 --- a/src/init/starship.ps1 +++ b/src/init/starship.ps1 @@ -27,6 +27,7 @@ function global:prompt { $startInfo = [System.Diagnostics.ProcessStartInfo]::new($Executable); $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8; $startInfo.RedirectStandardOutput = $true; + $startInfo.RedirectStandardError = $true; $startInfo.CreateNoWindow = $true; $startInfo.UseShellExecute = $false; if ($startInfo.ArgumentList.Add) { @@ -48,7 +49,17 @@ function global:prompt { } $startInfo.Arguments = $escaped -Join ' '; } - [System.Diagnostics.Process]::Start($startInfo).StandardOutput.ReadToEnd(); + $process = [System.Diagnostics.Process]::Start($startInfo) + + # stderr isn't displayed with this style of invocation + # Manually write it to console + $stderr = $process.StandardError.ReadToEnd().Trim() + if ($stderr -ne '') { + # Write-Error doesn't work here + $host.ui.WriteErrorLine($stderr) + } + + $process.StandardOutput.ReadToEnd(); } $origDollarQuestion = $global:?