X-Git-Url: https://vilimpoc.org/repos/dotfiles/blobdiff_plain/4658d6ddc8aaaa7e6b52fe3939151d3b35ddacab..d254a9bebd5448269d34a5c6dfcd36b646659b31:/setup-windows-no-uac.ps1 diff --git a/setup-windows-no-uac.ps1 b/setup-windows-no-uac.ps1 index 2a104fb..50cdd89 100644 --- a/setup-windows-no-uac.ps1 +++ b/setup-windows-no-uac.ps1 @@ -373,7 +373,17 @@ function Set-GlobalGitConfig { # run would otherwise read as success. $global: because a bare assignment # would make a local copy that the native call then does not update. $global:LASTEXITCODE = $null - try { $version = (& $cand -V 2>&1 | Select-Object -First 1) } catch { } + # Collect ALL the output, THEN take its first line. Piped straight into + # `Select-Object -First 1`, which is how this used to read, PowerShell + # stops the pipeline the moment ssh.exe prints its banner - before it + # has exited - kills it, and the exit code comes back -1 instead of 0. + # Measured under Windows PowerShell 5.1 against a healthy + # C:\Tools\rsync\ssh.exe: 19 of 20 runs reported -1 that way, 0 of 20 + # once collected first. So this check usually judged the fast client + # broken and handed git the in-box one it exists to avoid. + # setup-windows-with-uac.ps1 fixed the same trap in its own ssh.exe + # check (see DRAIN THE OUTPUT there); this copy was missed. + try { $sshOut = @(& $cand -V 2>&1); $version = $sshOut[0] } catch { } finally { $ErrorActionPreference = $prevEap } if ($LASTEXITCODE -eq 0) { $winSsh = $cand; break } $why = if ($null -eq $LASTEXITCODE) { 'it would not start' } else { "exit $LASTEXITCODE" }