Skip to content

Commit a9aa9b8

Browse files
committed
🤖 fix: use process substitution to avoid quoting issues
eval "$(...)" had nested quote conflicts with commands containing double quotes like --format="%(refname:short)". Use process substitution instead: bash <(echo BASE64 | base64 -d) This creates a file descriptor containing the decoded script, so: - Bash reads script from file descriptor (not stdin or quoted arg) - No quoting conflicts because script content isn't in quotes - Script can still redirect stdin freely (exec </dev/null works)
1 parent 7a5288a commit a9aa9b8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/node/utils/main/bashPath.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,13 @@ export function getSpawnConfig(runtime: BashRuntime, script: string, cwd?: strin
398398
// 2. The decode happens inside bash, so PowerShell never sees the script
399399
// 3. Single quotes in PowerShell pass the string literally to WSL
400400
//
401-
// IMPORTANT: Use eval "$(echo ... | base64 -d)" instead of "echo ... | base64 -d | bash"
402-
// The latter pipes to bash's stdin, which breaks if the script contains "exec </dev/null"
403-
// (that redirects stdin to /dev/null, cutting off the script mid-read).
404-
// Using eval with command substitution captures the entire decoded script first.
401+
// Use process substitution: bash <(echo BASE64 | base64 -d)
402+
// This creates a file descriptor containing the decoded script, so:
403+
// - Bash reads the script from the file descriptor (not stdin)
404+
// - The script can redirect stdin however it wants (e.g., exec </dev/null)
405+
// - No quoting issues because the script content is never in a quoted string
405406
const wslArgs = runtime.distro ? `-d ${runtime.distro}` : "";
406-
const psCommand = `wsl ${wslArgs} bash -c 'eval "$(echo ${base64Script} | base64 -d)"'`.trim();
407+
const psCommand = `wsl ${wslArgs} bash -c 'bash <(echo ${base64Script} | base64 -d)'`.trim();
407408

408409
return {
409410
command: psPath,

0 commit comments

Comments
 (0)