fix: Store $? and $LASTEXITCODE first in PowerShell (#3316)
These need to be stored before calling any PowerShell function or executable. Otherwise the values will be overwritten and cannot be properly restored or passed to starship. Fixes: #3315
This commit is contained in:
parent
3c379693e1
commit
b21904c9d3
|
@ -63,6 +63,9 @@ function global:prompt {
|
|||
$process.StandardOutput.ReadToEnd();
|
||||
}
|
||||
|
||||
$origDollarQuestion = $global:?
|
||||
$origLastExitCode = $global:LASTEXITCODE
|
||||
|
||||
# Invoke precmd, if specified
|
||||
try {
|
||||
if (Test-Path function:Invoke-Starship-PreCommand) {
|
||||
|
@ -70,9 +73,6 @@ function global:prompt {
|
|||
}
|
||||
} catch {}
|
||||
|
||||
$origDollarQuestion = $global:?
|
||||
$origLastExitCode = $global:LASTEXITCODE
|
||||
|
||||
# @ makes sure the result is an array even if single or no values are returned
|
||||
$jobs = @(Get-Job | Where-Object { $_.State -eq 'Running' }).Count
|
||||
|
||||
|
|
Loading…
Reference in New Issue