uninstall.ps1: exit 0 on success (do not leak WSL probe exit code)

The WSL distro-probe loop tries a candidate list that intentionally
includes distros that may not exist; the last failed `wsl -d <name> -- true`
probe left $LASTEXITCODE=255, so `& .\uninstall.ps1` returned non-zero even
when every cleanup step succeeded. Reset $global:LASTEXITCODE=0 at the end
(not `exit 0`, so the `irm ... | iex` usage does not kill the caller shell).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Han 2026-06-03 05:29:31 -07:00
commit 27f045a412

View file

@ -414,6 +414,15 @@ function Uninstall-UnslothStudio {
Write-Host "set to also remove that install tree, e.g.:"
Write-Host " `$env:UNSLOTH_STUDIO_HOME = 'C:\your\path'; irm https://raw.githubusercontent.com/unslothai/unsloth/main/scripts/uninstall.ps1 | iex"
}
# A successful uninstall must report success. The WSL distro-probe loop above
# leaves $LASTEXITCODE set by the last `wsl -d <name> -- true` probe, and the
# candidate list intentionally includes distros that may not exist (their
# probes fail by design) -- so without this reset `& .\uninstall.ps1` would
# exit non-zero (255) even though every cleanup step succeeded. Set the var
# rather than calling `exit 0` so the `irm ... | iex` usage does not terminate
# the caller's shell.
$global:LASTEXITCODE = 0
}
Uninstall-UnslothStudio @args