Skip to content

Commit fdae697

Browse files
anandgupta42claude
andcommitted
fix: [#958] pass installer test args as bareword command-line tokens
Array splatting binds positionally, so -Version still became a string value ($Version = "-Version"). Pass the args as bareword tokens after the script path (`& 'script' -Version 0.0.0-nonexistent`) so parameter names bind as names, matching the original `pwsh -File <script> @ScriptArgs` behavior. The harness only ever passes shell-safe tokens. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent daa66cc commit fdae697

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎test/windows/install.Tests.ps1‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ BeforeAll {
4141
$preamble += "`$env:$k = '$vEsc'; "
4242
}
4343
}
44-
# Splat the args as a child-side ARRAY so tokens like -Version / -Help bind
45-
# as parameter names. Passing them as quoted literals in a call expression
46-
# would instead bind them positionally as string VALUES (e.g. $Version would
47-
# become "-Version"); array splatting preserves command-line param parsing.
48-
$parts = @()
49-
foreach ($a in $ScriptArgs) { $parts += "'" + $a.Replace($sq, $escSq) + "'" }
50-
$argArray = $parts -join ","
44+
# Pass the script args as bareword command-line tokens (e.g. `-Version
45+
# 0.0.0-nonexistent`) so parameter NAMES bind as names - matching the
46+
# original `pwsh -File <script> @ScriptArgs` semantics. Quoting them as
47+
# literals (or array-splatting) binds positionally instead, so $Version
48+
# would receive the literal string "-Version". The harness only ever passes
49+
# shell-safe tokens (-Help, -Version, version strings; no spaces/quotes).
50+
$argTokens = $ScriptArgs -join " "
5151
$scriptEsc = $script:InstallScript.Replace($sq, $escSq)
52-
$command = "$preamble `$__args = @($argArray); & '$scriptEsc' @__args"
52+
$command = "$preamble & '$scriptEsc' $argTokens"
5353
$output = & pwsh -NoProfile -Command $command 2>&1 | Out-String
5454
return @{ Code = $LASTEXITCODE; Output = $output }
5555
}

0 commit comments

Comments
 (0)