Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
child-process: use case-insensitive comparison to check shell name
  • Loading branch information
tkamenoko authored and joaocgreis committed Sep 1, 2018
commit a4122b7f10cb0f72a0793d636a25218ab391d0f4
2 changes: 1 addition & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function normalizeSpawnArguments(file, args, options) {
else
file = process.env.comspec || 'cmd.exe';
// '/d /s /c' is used only for cmd.exe.
if (file.endsWith('cmd.exe') || file.endsWith('cmd')) {
if (/^(?:.*\\)?cmd(?:\.exe)?$/i.test(file)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A late comment, I think that \b might be a simpler test for the prefix:

if (/\bcmd(\.exe)?$/i.test(file)) 

also IMHO no need to ?: the groups since we just .test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P.S. I would call my comment a "nit" (that is a non blocking style change)

args = ['/d', '/s', '/c', `"${command}"`];
} else {
args = ['-c', command];
Expand Down