diff options
| author | Chris Denton <christophersdenton@gmail.com> | 2022-12-28 19:41:42 +0000 |
|---|---|---|
| committer | Chris Denton <christophersdenton@gmail.com> | 2022-12-28 19:41:42 +0000 |
| commit | 96501bdbe491e0232ca74d3a3cc15c26a1716e37 (patch) | |
| tree | 6e8b70422192dc9a140a9ba5484097ac6163c76d /x.ps1 | |
| parent | 874cefad9bd636671c87336ad470958c9ad26a43 (diff) | |
| download | rust-96501bdbe491e0232ca74d3a3cc15c26a1716e37.tar.gz rust-96501bdbe491e0232ca74d3a3cc15c26a1716e37.zip | |
Powershell: Create a `Start-Process` wrapper
Diffstat (limited to 'x.ps1')
| -rwxr-xr-x | x.ps1 | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/x.ps1 b/x.ps1 index 8f2d724a8d0..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,17 +29,14 @@ foreach ($python in "py", "python3", "python", "python2") { # Use python3, not python2 $xpy_args = @("-3") + $xpy_args } - $process = Start-Process -NoNewWindow -PassThru $python $xpy_args - $process.WaitForExit() - 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" |
