about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-03 23:17:21 +0000
committerbors <bors@rust-lang.org>2023-05-03 23:17:21 +0000
commitf557a4fd462a779c92e4e8bd004426cf329efb30 (patch)
tree863a4f47f25435437fd93c618b56dae3dff5cfe8
parent473f916d836cc662c5bdbb0d40af9fb4678fab9e (diff)
parent9ea7142a013eeb857a8922caf2ec485a056e987f (diff)
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
-rwxr-xr-xx.ps17
1 files changed, 7 insertions, 0 deletions
diff --git a/x.ps1 b/x.ps1
index f324a4676c8..b0cddc9f930 100755
--- a/x.ps1
+++ b/x.ps1
@@ -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
 }