about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2023-05-03 16:06:16 +0100
committerChris Denton <chris@chrisdenton.dev>2023-05-03 18:21:36 +0100
commit9ea7142a013eeb857a8922caf2ec485a056e987f (patch)
tree936e2a2badc2c23eeaee8772ac30d91ec1523a6f
parent82cd953c7c43e64dae6f705ce2f07b291f0e22e3 (diff)
downloadrust-9ea7142a013eeb857a8922caf2ec485a056e987f.tar.gz
rust-9ea7142a013eeb857a8922caf2ec485a056e987f.zip
Return error code from x.ps1
-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
 }