Skip to content

Commit

Permalink
Auto merge of rust-lang#111141 - ChrisDenton:ps-exitcode, r=jyn514
Browse files Browse the repository at this point in the history
Return error code from x.ps1

Fixes rust-lang#111136

This works around a bug where `ExitCode` does not return the exit code. See: https://stackoverflow.com/a/23797762
  • Loading branch information
bors committed May 3, 2023
2 parents 473f916 + 9ea7142 commit f557a4f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions x.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ function Get-Application($app) {

function Invoke-Application($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()
if ($null -eq $process.ExitCode) {
Write-Error "Unable to read the exit code"
Exit 1
}
Exit $process.ExitCode
}

Expand Down

0 comments on commit f557a4f

Please sign in to comment.