End of CLI options `--` is now part of `process.execArgv` (regression in Node 10.10)
- 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