Skip to content

End of CLI options -- is now part of process.execArgv (regression in Node 10.10) #24647

Closed
@demurgos

Description

  • Version: 11.2.0
  • Platform: Linux 64 bit
  • Subsystem: src

I noticed a regression regarding -- following the refactoring in 8fd55fffee (#22392).

  • Node < 10.10:

    $ echo "console.log(process.execArgv)" > test.js
    $ node -- test.js
    []
    
  • Node >= 10.10

    $ echo "console.log(process.execArgv)" > test.js
    $ node -- test.js
    [ '--' ]
    

The double dash indicating the end of the exec args is now part of process.execArgv while it previously was neither in process.execArgv nor process.argv. This prevents from safely spawning a Node process while escaping the main module name. The following pattern to respawn itself no longer works:

const args = [...process.exevArgv, "--", ...process.argv.slice(1)];
cp.spawn(process.execPath, args);

Calling node -- foo.js results in node -- -- foo.js in Node > 10.10 (it worked fine previously).

I caught it in CI when working on spawn-wrap, a lib that heavily depends on how the node processes are spawned: https://travis-ci.org/demurgos/spawn-wrap/jobs/459508703

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

cliIssues and PRs related to the Node.js command line interface.regressionIssues related to regressions.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions