Auto merge of #111141 - ChrisDenton:ps-exitcode, r=jyn514
Return error code from x.ps1 Fixes #111136 This works around a bug where `ExitCode` does not return the exit code. See: https://stackoverflow.com/a/23797762
This commit is contained in:
commit
f557a4fd46
7
x.ps1
7
x.ps1
@ -16,7 +16,14 @@ function Get-Application($app) {
|
|||||||
|
|
||||||
function Invoke-Application($application, $arguments) {
|
function Invoke-Application($application, $arguments) {
|
||||||
$process = Start-Process -NoNewWindow -PassThru $application $arguments
|
$process = Start-Process -NoNewWindow -PassThru $application $arguments
|
||||||
|
# WORKAROUND: Caching the handle is necessary to make ExitCode work.
|
||||||
|
# See https://stackoverflow.com/a/23797762
|
||||||
|
$handle = $process.Handle
|
||||||
$process.WaitForExit()
|
$process.WaitForExit()
|
||||||
|
if ($null -eq $process.ExitCode) {
|
||||||
|
Write-Error "Unable to read the exit code"
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
Exit $process.ExitCode
|
Exit $process.ExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user