Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: fix omitting -- from process.execArgv #24654

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node_options-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ struct ArgsInfo {
// on the command line (i.e. not generated through alias expansion).
// '--' is a special case here since its purpose is to end `exec_argv`,
// which is why we do not include it.
if (exec_args != nullptr && first() != "--")
if (exec_args != nullptr && ret != "--")
exec_args->push_back(ret);
underlying->erase(underlying->begin() + 1);
} else {
Expand Down
23 changes: 13 additions & 10 deletions test/parallel/test-process-exec-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ const spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
process.stdout.write(JSON.stringify(process.execArgv));
} else {
const execArgv = ['--stack-size=256'];
const args = [__filename, 'child', 'arg0'];
const child = spawn(process.execPath, execArgv.concat(args));
let out = '';
for (const extra of [ [], [ '--' ] ]) {
const execArgv = ['--stack-size=256'];
const args = [__filename, 'child', 'arg0'];
const child = spawn(process.execPath, [...execArgv, ...extra, ...args]);
let out = '';

child.stdout.on('data', function(chunk) {
out += chunk;
});
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
out += chunk;
});

child.on('close', function() {
assert.deepStrictEqual(JSON.parse(out), execArgv);
});
child.on('close', function() {
assert.deepStrictEqual(JSON.parse(out), execArgv);
});
}
}