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

child_process: refactor normalizeSpawnArguments() #14149

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 5 additions & 3 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,11 @@ function normalizeSpawnArguments(file, args, options) {
const command = [file].concat(args).join(' ');

if (process.platform === 'win32') {
file = typeof options.shell === 'string' ? options.shell :
process.env.comspec || 'cmd.exe';
args = ['/d', '/s', '/c', '"' + command + '"'];
if (typeof options.shell === 'string')
file = options.shell;
else
file = process.env.comspec || 'cmd.exe';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you touched this. I'm not sure an environment without a comspec is valid...
@nodejs/platform-windows

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@refack No, it is not, at least not in the top-level environment. %COMSPEC% must always be a valid path to an executable acting as the "shell". However, the value of %COMSPEC% can be modified by users and can be overriden and/or deleted for child processes. Windows will not prevent that, even though it is not intended behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same way a user can remove cmd.exe from the Path or from the system completely.
IMHO we should deprecate the || 'cmd.exe' part.

Ref: #14156
Ref: #14157

args = ['/d', '/s', '/c', `"${command}"`];
options.windowsVerbatimArguments = true;
} else {
if (typeof options.shell === 'string')
Expand Down