@@ -133,9 +133,8 @@ added: v0.1.90
133133 * ` env ` {Object} Environment key-value pairs
134134 * ` encoding ` {string} (Default: ` 'utf8' ` )
135135 * ` shell ` {string} Shell to execute the command with
136- (Default: ` '/bin/sh' ` on UNIX, ` 'cmd.exe' ` on Windows, The shell should
137- understand the ` -c ` switch on UNIX or ` /d /s /c ` on Windows. On Windows,
138- command line parsing should be compatible with ` cmd.exe ` .)
136+ (Default: ` '/bin/sh' ` on UNIX, ` process.env.ComSpec ` on Windows. See
137+ [ Shell Requirements] [ ] and [ Default Windows Shell] [ ] .)
139138 * ` timeout ` {number} (Default: ` 0 ` )
140139 * ` maxBuffer ` {number} Largest amount of data in bytes allowed on stdout or
141140 stderr. (Default: ` 200*1024 ` ) If exceeded, the child process is terminated.
@@ -382,9 +381,9 @@ changes:
382381 * ` uid ` {number} Sets the user identity of the process. (See setuid(2).)
383382 * ` gid ` {number} Sets the group identity of the process. (See setgid(2).)
384383 * ` shell ` {boolean|string} If ` true ` , runs ` command ` inside of a shell. Uses
385- ` '/bin/sh' ` on UNIX, and ` 'cmd.exe' ` on Windows. A different shell can be
386- specified as a string. The shell should understand the ` -c ` switch on UNIX,
387- or ` /d /s /c ` on Windows. Defaults to ` false ` (no shell).
384+ ` '/bin/sh' ` on UNIX, and ` process.env.ComSpec ` on Windows. A different
385+ shell can be specified as a string. See [ Shell Requirements ] [ ] and
386+ [ Default Windows Shell ] [ ] . Defaults to ` false ` (no shell).
388387* Returns: {ChildProcess}
389388
390389The ` child_process.spawn() ` method spawns a new process using the given
@@ -707,9 +706,8 @@ changes:
707706 ` stdio ` is specified
708707 * ` env ` {Object} Environment key-value pairs
709708 * ` shell ` {string} Shell to execute the command with
710- (Default: ` '/bin/sh' ` on UNIX, ` 'cmd.exe' ` on Windows, The shell should
711- understand the ` -c ` switch on UNIX or ` /d /s /c ` on Windows. On Windows,
712- command line parsing should be compatible with ` cmd.exe ` .)
709+ (Default: ` '/bin/sh' ` on UNIX, ` process.env.ComSpec ` on Windows. See
710+ [ Shell Requirements] [ ] and [ Default Windows Shell] [ ] .)
713711 * ` uid ` {number} Sets the user identity of the process. (See setuid(2).)
714712 * ` gid ` {number} Sets the group identity of the process. (See setgid(2).)
715713 * ` timeout ` {number} In milliseconds the maximum amount of time the process
@@ -775,9 +773,9 @@ changes:
775773 * ` encoding ` {string} The encoding used for all stdio inputs and outputs.
776774 (Default: ` 'buffer' ` )
777775 * ` shell ` {boolean|string} If ` true ` , runs ` command ` inside of a shell. Uses
778- ` '/bin/sh' ` on UNIX, and ` 'cmd.exe' ` on Windows. A different shell can be
779- specified as a string. The shell should understand the ` -c ` switch on UNIX,
780- or ` /d /s /c ` on Windows. Defaults to ` false ` (no shell).
776+ ` '/bin/sh' ` on UNIX, and ` process.env.ComSpec ` on Windows. A different
777+ shell can be specified as a string. See [ Shell Requirements ] [ ] and
778+ [ Default Windows Shell ] [ ] . Defaults to ` false ` (no shell).
781779* Returns: {Object}
782780 * ` pid ` {number} Pid of the child process
783781 * ` output ` {Array} Array of results from stdio output
@@ -1281,6 +1279,19 @@ This impacts output that includes multibyte character encodings such as UTF-8 or
12811279UTF-16. For instance, ` console.log('中文测试') ` will send 13 UTF-8 encoded bytes
12821280to ` stdout ` although there are only 4 characters.
12831281
1282+ ## Shell Requirements
1283+
1284+ The shell should understand the ` -c ` switch on UNIX or ` /d /s /c ` on Windows.
1285+ On Windows, command line parsing should be compatible with ` 'cmd.exe' ` .
1286+
1287+ ## Default Windows Shell
1288+
1289+ Although Microsoft specifies ` %COMSPEC% ` must contain the path to
1290+ ` 'cmd.exe' ` in the root environment, child processes are not always subject to
1291+ the same requirement. Thus, in ` child_process ` functions where a shell can be
1292+ spawned, ` 'cmd.exe' ` is used as a fallback if ` process.env.ComSpec ` is
1293+ unavailable.
1294+
12841295[ `'error'` ] : #child_process_event_error
12851296[ `'exit'` ] : #child_process_event_exit
12861297[ `'message'` ] : #child_process_event_message
@@ -1314,4 +1325,6 @@ to `stdout` although there are only 4 characters.
13141325[ `process.send()` ] : process.html#process_process_send_message_sendhandle_options_callback
13151326[ `stdio` ] : #child_process_options_stdio
13161327[ `util.promisify()` ] : util.html#util_util_promisify_original
1328+ [ Default Windows Shell ] : #child_process_default_windows_shell
1329+ [ Shell Requirements ] : #child_process_shell_requirements
13171330[ synchronous counterparts ] : #child_process_synchronous_process_creation
0 commit comments