install.ps1: fix PropertyNotFoundStrict crash in the PATH check
Under the script's own Set-StrictMode -Version Latest, .Count on the result of Where-Object throws when the filter matches nothing — which is precisely the fresh-install case (bin dir not on PATH yet), so every first-time Windows install ended with an error after an otherwise successful install. Use -contains on the split arrays instead; no member access on a possibly-null pipeline result. Repro + fix verified under pwsh 7.5.2 with StrictMode Latest: old expression reproduces the user's exact error, new one returns False/True correctly for missing/present PATH entries.
This commit is contained in:
+5
-2
@@ -131,9 +131,12 @@ try {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "kigi v$ResolvedVersion installed to $Dest"
|
Write-Host "kigi v$ResolvedVersion installed to $Dest"
|
||||||
|
|
||||||
|
# -contains instead of Where-Object/.Count: under Set-StrictMode, .Count
|
||||||
|
# on an empty (null) filter result throws PropertyNotFoundStrict — which
|
||||||
|
# fired on every fresh install, since that's exactly the not-on-PATH case.
|
||||||
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
$OnPath = ($UserPath -split ";" | Where-Object { $_ -eq $BinDir }).Count -gt 0 -or
|
$OnPath = (($UserPath -split ";") -contains $BinDir) -or
|
||||||
($env:Path -split ";" | Where-Object { $_ -eq $BinDir }).Count -gt 0
|
(($env:Path -split ";") -contains $BinDir)
|
||||||
if (-not $OnPath) {
|
if (-not $OnPath) {
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "$BinDir is not on your PATH. Add it for the current user with:"
|
Write-Host "$BinDir is not on your PATH. Add it for the current user with:"
|
||||||
|
|||||||
Reference in New Issue
Block a user