GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

New issue
Copy link
New issue
Copy link
Closed
Closed
child_process.spawn adds flags that might cause non-native shells to fail on windows#19947
Copy link
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

@idanpa
idanpa
opened on Apr 11, 2018
Issue body actions
  • 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

  1. vsemozhetbyt commented on Apr 11, 2018

    @vsemozhetbyt
    vsemozhetbyt
    on Apr 11, 2018
    Contributor
    More actions

    FWIW, we warn about this in docs:

    https://nodejs.org/api/child_process.html#child_process_shell_requirements

  2. vsemozhetbyt
    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, 2018
  3. bnoordhuis commented on Apr 11, 2018

    @bnoordhuis
    bnoordhuis
    on Apr 11, 2018
    Member
    More actions

    Yep, and it doesn't seem like an unreasonable restriction to me. I don't really see how we could improve it either.

  4. idanpa commented on Apr 11, 2018

    @idanpa
    idanpa
    on Apr 11, 2018
    Author
    More actions

    @bnoordhuis what do you say about these options:

    1. Having shellOptions arg with default value '/d /s /c' on windows and '-sc' on unix
    2. Skip adding the options if shell string already contains flags (having either " -" or " /"
    3. Having 2 different optional args - shshell and ntshell that gets the right options accordingly (without checking the platform)
  5. bnoordhuis commented on Apr 11, 2018

    @bnoordhuis
    bnoordhuis
    on Apr 11, 2018
    Member
    More actions

    (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.

  6. bnoordhuis commented on Apr 23, 2018

    @bnoordhuis
    bnoordhuis
    on Apr 23, 2018
    Member
    More actions

    I'll close this out. It's been two weeks and no one spoke out in favor of making changes.

  7. bnoordhuis
    closed this as completedon Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.