Skip to content

Commit 1eaf990

Browse files
committed
🤖 fix: use [Console]::In.ReadToEnd() for PowerShell stdin
PowerShell's $input automatic variable doesn't work reliably with -Command because it's designed for pipeline input in functions/filters, not for reading stdin directly. Use [Console]::In.ReadToEnd() instead.
1 parent 8053346 commit 1eaf990

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/node/utils/main/bashPath.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,17 @@ export function getSpawnConfig(runtime: BashRuntime, script: string, cwd?: strin
377377
// -NoProfile: faster startup, avoids profile execution policy issues
378378
// -WindowStyle Hidden: hide console window
379379
// -Command: execute the piped command
380+
// Use [Console]::In.ReadToEnd() instead of $input because $input doesn't work
381+
// reliably with -Command (it's meant for pipeline input in functions/filters)
380382
return {
381383
command: psPath,
382-
args: ["-NoProfile", "-WindowStyle", "Hidden", "-Command", `$input | ${wslCmd}`],
384+
args: [
385+
"-NoProfile",
386+
"-WindowStyle",
387+
"Hidden",
388+
"-Command",
389+
`[Console]::In.ReadToEnd() | ${wslCmd}`,
390+
],
383391
cwd: undefined, // cwd is embedded in the script
384392
stdin: fullScript,
385393
};

0 commit comments

Comments
 (0)