From c13bfdc0913d5828c049d727b1890fc9e398724c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 29 Jul 2013 16:20:24 +0200 Subject: [PATCH] child_process: add 'shell' option to .exec() No test, we can't rely on an alternate shell being available. Fixes #5935. --- doc/api/child_process.markdown | 4 ++++ lib/child_process.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index 846649429ae..4aef436371a 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -464,6 +464,10 @@ See also: `child_process.exec()` and `child_process.fork()` * `cwd` {String} Current working directory of the child process * `env` {Object} Environment key-value pairs * `encoding` {String} (Default: 'utf8') + * `shell` {String} Shell to execute the command with + (Default: '/bin/sh' on UNIX, 'cmd.exe' on Windows, The shell should + understand the `-c` switch on UNIX or `/s /c` on Windows. On Windows, + command line parsing should be compatible with `cmd.exe`.) * `timeout` {Number} (Default: 0) * `maxBuffer` {Number} (Default: 200*1024) * `killSignal` {String} (Default: 'SIGTERM') diff --git a/lib/child_process.js b/lib/child_process.js index cfb40f06725..b034fa65c6b 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -576,6 +576,10 @@ exports.exec = function(command /*, options, callback */) { file = '/bin/sh'; args = ['-c', command]; } + + if (options && options.shell) + file = options.shell; + return exports.execFile(file, args, options, callback); };