Skip to content

Commit 9ea7142

Browse files
committed
Return error code from x.ps1
1 parent 82cd953 commit 9ea7142

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: x.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ function Get-Application($app) {
1616

1717
function Invoke-Application($application, $arguments) {
1818
$process = Start-Process -NoNewWindow -PassThru $application $arguments
19+
# WORKAROUND: Caching the handle is necessary to make ExitCode work.
20+
# See https://stackoverflow.com/a/23797762
21+
$handle = $process.Handle
1922
$process.WaitForExit()
23+
if ($null -eq $process.ExitCode) {
24+
Write-Error "Unable to read the exit code"
25+
Exit 1
26+
}
2027
Exit $process.ExitCode
2128
}
2229

0 commit comments

Comments
 (0)