diff --git a/windows/lib/common.ps1 b/windows/lib/common.ps1 index 64ace7b..9907155 100644 --- a/windows/lib/common.ps1 +++ b/windows/lib/common.ps1 @@ -745,7 +745,10 @@ function Invoke-LxsSibling { $local = Join-Path $SelfDirectory $name if (Test-Path $local) { $global:LASTEXITCODE = 0 - & $local @Arguments + # Out-Host, not a bare call: anything the child writes to the success + # stream (native command output, for one) would otherwise be collected + # into this function's return value alongside the exit code. + & $local @Arguments | Out-Host return $LASTEXITCODE } @@ -765,7 +768,7 @@ function Invoke-LxsSibling { Write-LxsOk 'Payload acquired' try { $global:LASTEXITCODE = 0 - & $temp @Arguments + & $temp @Arguments | Out-Host return $LASTEXITCODE } finally { Remove-Item $temp -Force -ErrorAction SilentlyContinue diff --git a/windows/lxs.ps1 b/windows/lxs.ps1 index 6ce4613..363327d 100644 --- a/windows/lxs.ps1 +++ b/windows/lxs.ps1 @@ -224,8 +224,11 @@ function Invoke-LxsScript { Write-Host '' $global:LASTEXITCODE = 0 + $code = 0 try { - & $target @Arguments + # Out-Host keeps the child's success-stream output out of this + # function's return value, which must be just the exit code. + & $target @Arguments | Out-Host $code = $LASTEXITCODE } finally { if ($temp) { Remove-Item $temp -Force -ErrorAction SilentlyContinue }