summaryrefslogtreecommitdiff
path: root/doc/api/child_process.md
diff options
context:
space:
mode:
authorBartosz Sosnowski <bartosz@janeasystems.com>2016-06-30 16:58:24 +0200
committerEvan Lucas <evanlucas@me.com>2016-08-24 07:50:51 -0500
commit4a8aca7f9407878eebcfd168c9dcb60ab53dd692 (patch)
treeda91503c917913ba48bef434291d81c7748993fc /doc/api/child_process.md
parent4f09886dce0072b7646e07f0ca90b84b57f6af02 (diff)
downloadnode-new-4a8aca7f9407878eebcfd168c9dcb60ab53dd692.tar.gz
doc: script with spaces spawn example for windows
Adds an example of how to spawn a shell script under Windows with spaces in its filename. Ref: https://github.com/nodejs/node/issues/7367 PR-URL: https://github.com/nodejs/node/pull/8035 Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/child_process.md')
-rw-r--r--doc/api/child_process.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/api/child_process.md b/doc/api/child_process.md
index fe265afc12..a01b0db9b2 100644
--- a/doc/api/child_process.md
+++ b/doc/api/child_process.md
@@ -82,7 +82,8 @@ be launched using [`child_process.execFile()`][]. When running on Windows, `.bat
and `.cmd` files can be invoked using [`child_process.spawn()`][] with the `shell`
option set, with [`child_process.exec()`][], or by spawning `cmd.exe` and passing
the `.bat` or `.cmd` file as an argument (which is what the `shell` option and
-[`child_process.exec()`][] do).
+[`child_process.exec()`][] do). In any case, if the script filename contains
+spaces it needs to be quoted.
```js
// On Windows Only ...
@@ -110,6 +111,13 @@ exec('my.bat', (err, stdout, stderr) => {
}
console.log(stdout);
});
+
+// Script with spaces in the filename:
+const bat = spawn('"my script.cmd"', ['a', 'b'], { shell:true });
+// or:
+exec('"my script.cmd" a b', (err, stdout, stderr) => {
+ // ...
+});
```
### child_process.exec(command[, options][, callback])