Rollup merge of #118782 - jyn514:powershell, r=ChrisDenton · rust-lang/rust@dd23469 (original) (raw)
`@@ -8,29 +8,16 @@ $ErrorActionPreference = "Stop"
`
8
8
`Get-Command -syntax PSCommandPath>{PSCommandPath} >PSCommandPath>null
`
9
9
``
10
10
`$xpy = Join-Path $PSScriptRoot x.py
`
11
``
`-
Start-Process for some reason splits arguments on spaces. (Isn't powershell supposed to be simpler than bash?)
`
12
``
`-
Double-quote all the arguments so it doesn't do that.
`
13
``
`- xpyargs=@("""xpy_args = @("""xpyargs=@("""xpy""")
`
14
``
`-
foreach ($arg in $args) {
`
15
``
`- xpyargs+="""xpy_args += """xpyargs+="""arg"""
`
16
``
`-
}
`
``
11
`+ xpyargs=@(xpy_args = @(xpyargs=@(xpy) + $args
`
17
12
``
18
13
`function Get-Application($app) {
`
19
14
`$cmd = Get-Command $app -ErrorAction SilentlyContinue -CommandType Application | Select-Object -First 1
`
20
15
`return $cmd
`
21
16
`}
`
22
17
``
23
18
`function Invoke-Application($application, $arguments) {
`
24
``
`- process=Start−Process−NoNewWindow−PassThruprocess = Start-Process -NoNewWindow -PassThru process=Start−Process−NoNewWindow−PassThruapplication $arguments
`
25
``
`-
WORKAROUND: Caching the handle is necessary to make ExitCode work.
`
26
``
`-
See https://stackoverflow.com/a/23797762
`
27
``
`- handle=handle = handle=process.Handle
`
28
``
`-
$process.WaitForExit()
`
29
``
`-
if ($null -eq $process.ExitCode) {
`
30
``
`-
Write-Error "Unable to read the exit code"
`
31
``
`-
Exit 1
`
32
``
`-
}
`
33
``
`-
Exit $process.ExitCode
`
``
19
`+
& applicationapplication applicationarguments
`
``
20
`+
Exit $LASTEXITCODE
`
34
21
`}
`
35
22
``
36
23
`foreach ($python in "py", "python3", "python", "python2") {
`