Skip to content

Commit c0fde48

Browse files
committed
🤖 fix: quote $s variable when passing to bash -c
Without quotes, PowerShell expands $s and bash only receives the first word as the -c argument. The rest becomes positional args to bash. Use escaped double quotes (\`"$s\`") so the entire decoded script is passed as a single argument to bash -c.
1 parent dcc7f77 commit c0fde48

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/node/utils/main/bashPath.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,14 @@ export function getSpawnConfig(runtime: BashRuntime, script: string, cwd?: strin
395395

396396
// Build the PowerShell command that:
397397
// 1. Decodes the base64 script into variable $s
398-
// 2. Passes $s to WSL bash -c (not stdin piping - that loses output)
398+
// 2. Passes $s to WSL bash -c with proper quoting
399399
const wslArgs = runtime.distro ? `-d ${runtime.distro}` : "";
400-
// Use Invoke-Expression to run the wsl command with the decoded script
401-
// This ensures stdout/stderr are properly captured
400+
// CRITICAL: Must quote $s with escaped double quotes (`"$s`") so the entire
401+
// script is passed as a single argument to bash -c. Without quotes, PowerShell
402+
// expands $s and bash only sees the first word as the -c argument.
402403
const psCommand =
403404
`$s=[System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${base64Script}'));` +
404-
`wsl ${wslArgs} bash -c $s`.trim();
405+
`wsl ${wslArgs} bash -c \`"$s\`"`.trim();
405406

406407
return {
407408
command: psPath,

0 commit comments

Comments
 (0)