refactor(windows): ensure output redirection for Invoke-LxsSibling and Invoke-LxsScript
This commit is contained in:
@@ -745,7 +745,10 @@ function Invoke-LxsSibling {
|
|||||||
$local = Join-Path $SelfDirectory $name
|
$local = Join-Path $SelfDirectory $name
|
||||||
if (Test-Path $local) {
|
if (Test-Path $local) {
|
||||||
$global:LASTEXITCODE = 0
|
$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
|
return $LASTEXITCODE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,7 +768,7 @@ function Invoke-LxsSibling {
|
|||||||
Write-LxsOk 'Payload acquired'
|
Write-LxsOk 'Payload acquired'
|
||||||
try {
|
try {
|
||||||
$global:LASTEXITCODE = 0
|
$global:LASTEXITCODE = 0
|
||||||
& $temp @Arguments
|
& $temp @Arguments | Out-Host
|
||||||
return $LASTEXITCODE
|
return $LASTEXITCODE
|
||||||
} finally {
|
} finally {
|
||||||
Remove-Item $temp -Force -ErrorAction SilentlyContinue
|
Remove-Item $temp -Force -ErrorAction SilentlyContinue
|
||||||
|
|||||||
+4
-1
@@ -224,8 +224,11 @@ function Invoke-LxsScript {
|
|||||||
Write-Host ''
|
Write-Host ''
|
||||||
|
|
||||||
$global:LASTEXITCODE = 0
|
$global:LASTEXITCODE = 0
|
||||||
|
$code = 0
|
||||||
try {
|
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
|
$code = $LASTEXITCODE
|
||||||
} finally {
|
} finally {
|
||||||
if ($temp) { Remove-Item $temp -Force -ErrorAction SilentlyContinue }
|
if ($temp) { Remove-Item $temp -Force -ErrorAction SilentlyContinue }
|
||||||
|
|||||||
Reference in New Issue
Block a user