X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=x.ps1;h=f324a4676c8e99d5f338eaa0c11020db0f4b5e0b;hb=d044c1bde49f11f4a19bd9046786986c11935b22;hp=81b98919f436cdad411ed6f3c8c55a4180382720;hpb=6a4624d73b34153811f7642b89bd396306aa7843;p=rust.git diff --git a/x.ps1 b/x.ps1 index 81b98919f43..f324a4676c8 100755 --- a/x.ps1 +++ b/x.ps1 @@ -14,6 +14,12 @@ function Get-Application($app) { return Get-Command $app -ErrorAction SilentlyContinue -CommandType Application } +function Invoke-Application($application, $arguments) { + $process = Start-Process -NoNewWindow -PassThru $application $arguments + $process.WaitForExit() + Exit $process.ExitCode +} + foreach ($python in "py", "python3", "python", "python2") { # NOTE: this only tests that the command exists in PATH, not that it's actually # executable. The latter is not possible in a portable way, see @@ -23,16 +29,14 @@ foreach ($python in "py", "python3", "python", "python2") { # Use python3, not python2 $xpy_args = @("-3") + $xpy_args } - $process = Start-Process -NoNewWindow -Wait -PassThru $python $xpy_args - Exit $process.ExitCode + Invoke-Application $python $xpy_args } } $found = (Get-Application "python*" | Where-Object {$_.name -match '^python[2-3]\.[0-9]+(\.exe)?$'}) if (($null -ne $found) -and ($found.Length -ge 1)) { $python = $found[0] - $process = Start-Process -NoNewWindow -Wait -PassThru $python $xpy_args - Exit $process.ExitCode + Invoke-Application $python $xpy_args } Write-Error "${PSCommandPath}: error: did not find python installed"