GeezerVison is showing github.com — child_process.spawn adds flags that might cause non-native shells to fail on windows · Issue #19947 · nodejs/node
child_process.spawn adds flags that might cause non-native shells to fail on windows #19947
Labels
child_processIssues and PRs related to the child_process subsystem.windowsIssues and PRs related to the Windows platform.wslIssues and PRs related to the Windows Subsystem for Linux. Description
- Version: 8.11.1
- Platform: Windows 10 64 bit
- Subsystem: child_process
On Windows, when child_process.spawn is given the optional shell parameter (#4598) it makes an assumption that the shell would understand the /c /s flags (cmd.exe or powershell).
This limits the option to use bash (using WSL) on windows.
Can by bypassed by:
args = ["\"", cmd].concat(args, "\"");
currentSync = child.spawn("bash -c", args, {stdio: 'pipe', shell: "cmd.exe"});
But would be nice to have a better solution.
Thanks,
Idan
Activity
vsemozhetbyt commented on Apr 11, 2018
added
child_processIssues and PRs related to the child_process subsystem. windowsIssues and PRs related to the Windows platform. wslIssues and PRs related to the Windows Subsystem for Linux. on Apr 11, 2018bnoordhuis commented on Apr 11, 2018
Yep, and it doesn't seem like an unreasonable restriction to me. I don't really see how we could improve it either.
idanpa commented on Apr 11, 2018
@bnoordhuis what do you say about these options:
- Having shellOptions arg with default value '/d /s /c' on windows and '-sc' on unix
- Skip adding the options if shell string already contains flags (having either " -" or " /"
- Having 2 different optional args - shshell and ntshell that gets the right options accordingly (without checking the platform)
bnoordhuis commented on Apr 11, 2018
(1) and (3) are fixing a problem that isn't really a problem (don't use .shell, spawn the shell directly) and (2) is the kind of heuristic that can have false positives (e.g. / is also a path separator.)
I mean, yes, there are ways to solve your issue with more API options but the extra complexity doesn't seem worth it.
bnoordhuis commented on Apr 23, 2018
I'll close this out. It's been two weeks and no one spoke out in favor of making changes.
Metadata
Metadata
child_processIssues and PRs related to the child_process subsystem.windowsIssues and PRs related to the Windows platform.wslIssues and PRs related to the Windows Subsystem for Linux. Development
No branches or pull requestsIssue actions