From 750cb490e85c175b3fc75c58dd5c016f44ab636d Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Sat, 3 Jan 2026 17:52:56 +0800 Subject: [PATCH] fix: report proper `lastexitcode` when invoked from iex Signed-off-by: Chawye Hsu --- install.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index e217128..3a435f0 100644 --- a/install.ps1 +++ b/install.ps1 @@ -93,8 +93,10 @@ function Exit-Install { [Int] $ErrorCode = 1 ) - # Don't abort if invoked with iex that would close the PS session if ($IS_EXECUTED_FROM_IEX) { + # Don't abort with `exit` that would close the PS session if invoked + # with iex, yet set `LASTEXITCODE` for the caller to check + $Global:LASTEXITCODE = $ErrorCode break } else { exit $ErrorCode @@ -607,7 +609,7 @@ function Install-Scoop { $downloadZipsRequired = $False } catch { Write-Warning "$($_.Exception.Message)" - $Global:LastExitCode = 0 + $Global:LASTEXITCODE = 0 } finally { $env:HTTPS_PROXY = $old_https $env:HTTP_PROXY = $old_http