Skip to content

Commit

Permalink
Return error code from x.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed May 3, 2023
1 parent 82cd953 commit 9ea7142
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 9ea7142

Please sign in to comment.