| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 36ea472 commit 1107a49
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ implemented on top of [`child_process.spawn()`][] or [`child_process.spawnSync() | |||
| 44 | 44 | * [`child_process.exec()`][]: spawns a shell and runs a command within that shell, | |
| 45 | 45 | passing the `stdout` and `stderr` to a callback function when complete. | |
| 46 | 46 | * [`child_process.execFile()`][]: similar to [`child_process.exec()`][] except that | |
| 47 | - it spawns the command directly without first spawning a shell. | ||
| 47 | + it spawns the command directly without first spawning a shell by default. | ||
| 48 | 48 | * [`child_process.fork()`][]: spawns a new Node.js process and invokes a | |
| 49 | 49 | specified module with an IPC communication channel established that allows | |
| 50 | 50 | sending messages between parent and child. | |
@@ -78,7 +78,7 @@ when the child process terminates. | |||
| 78 | 78 | The importance of the distinction between [`child_process.exec()`][] and | |
| 79 | 79 | [`child_process.execFile()`][] can vary based on platform. On Unix-type operating | |
| 80 | 80 | systems (Unix, Linux, macOS) [`child_process.execFile()`][] can be more efficient | |
| 81 | - because it does not spawn a shell. On Windows, however, `.bat` and `.cmd` | ||
| 81 | + because it does not spawn a shell by default. On Windows, however, `.bat` and `.cmd` | ||
| 82 | 82 | files are not executable on their own without a terminal, and therefore cannot | |
| 83 | 83 | be launched using [`child_process.execFile()`][]. When running on Windows, `.bat` | |
| 84 | 84 | and `.cmd` files can be invoked using [`child_process.spawn()`][] with the `shell` | |
@@ -266,14 +266,18 @@ changes: | |||
| 266 | 266 | normally be created on Windows systems. **Default:** `false`. | |
| 267 | 267 | * `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is | |
| 268 | 268 | done on Windows. Ignored on Unix. **Default:** `false`. | |
| 269 | + * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses | ||
| 270 | + `'/bin/sh'` on UNIX, and `process.env.ComSpec` on Windows. A different | ||
| 271 | + shell can be specified as a string. See [Shell Requirements][] and | ||
| 272 | + [Default Windows Shell][]. **Default:** `false` (no shell). | ||
| 269 | 273 | * `callback` {Function} Called with the output when process terminates. | |
| 270 | 274 | * `error` {Error} | |
| 271 | 275 | * `stdout` {string|Buffer} | |
| 272 | 276 | * `stderr` {string|Buffer} | |
| 273 | 277 | * Returns: {ChildProcess} | |
| 274 | 278 | ||
| 275 | 279 | The `child_process.execFile()` function is similar to [`child_process.exec()`][] | |
| 276 | - except that it does not spawn a shell. Rather, the specified executable `file` | ||
| 280 | + except that it does not spawn a shell by default. Rather, the specified executable `file` | ||
| 277 | 281 | is spawned directly as a new process making it slightly more efficient than | |
| 278 | 282 | [`child_process.exec()`][]. | |
| 279 | 283 | ||
@@ -312,6 +316,10 @@ async function getVersion() { | |||
| 312 | 316 | getVersion(); | |
| 313 | 317 | ``` | |
| 314 | 318 | ||
| 319 | + *Note*: If the `shell` option is enabled, do not pass unsanitized user input | ||
| 320 | + to this function. Any input containing shell metacharacters may be used to | ||
| 321 | + trigger arbitrary command execution. | ||
| 322 | + | ||
| 315 | 323 | ### child_process.fork(modulePath[, args][, options]) | |
| 316 | 324 | <!-- YAML | |
| 317 | 325 | added: v0.5.0 | |
@@ -703,6 +711,10 @@ changes: | |||
| 703 | 711 | * `encoding` {string} The encoding used for all stdio inputs and outputs. **Default:** `'buffer'` | |
| 704 | 712 | * `windowsHide` {boolean} Hide the subprocess console window that would | |
| 705 | 713 | normally be created on Windows systems. **Default:** `false`. | |
| 714 | + * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses | ||
| 715 | + `'/bin/sh'` on UNIX, and `process.env.ComSpec` on Windows. A different | ||
| 716 | + shell can be specified as a string. See [Shell Requirements][] and | ||
| 717 | + [Default Windows Shell][]. **Default:** `false` (no shell). | ||
| 706 | 718 | * Returns: {Buffer|string} The stdout from the command. | |
| 707 | 719 | ||
| 708 | 720 | The `child_process.execFileSync()` method is generally identical to | |
@@ -719,6 +731,10 @@ If the process times out or has a non-zero exit code, this method ***will*** | |||
| 719 | 731 | throw an [`Error`][] that will include the full result of the underlying | |
| 720 | 732 | [`child_process.spawnSync()`][]. | |
| 721 | 733 | ||
| 734 | + *Note*: If the `shell` option is enabled, do not pass unsanitized user input | ||
| 735 | + to this function. Any input containing shell metacharacters may be used to | ||
| 736 | + trigger arbitrary command execution. | ||
| 737 | + | ||
| 722 | 738 | ### child_process.execSync(command[, options]) | |
| 723 | 739 | <!-- YAML | |
| 724 | 740 | added: v0.11.12 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments