child_process: clone spawn options argument
spawnSync() modifies the options argument. This commit makes a copy of options before any modifications occur. Fixes: https://github.com/iojs/io.js/issues/576 PR-URL: https://github.com/iojs/io.js/pull/579 Reviewed-By: Bert Belder <bertbelder@gmail.com>
This commit is contained in:
parent
88aaff9aa6
commit
785481149d
@ -931,6 +931,7 @@ function normalizeSpawnArguments(file /*, args, options*/) {
|
|||||||
else if (!util.isObject(options))
|
else if (!util.isObject(options))
|
||||||
throw new TypeError('options argument must be an object');
|
throw new TypeError('options argument must be an object');
|
||||||
|
|
||||||
|
options = util._extend({}, options);
|
||||||
args.unshift(file);
|
args.unshift(file);
|
||||||
|
|
||||||
var env = options.env || process.env;
|
var env = options.env || process.env;
|
||||||
|
@ -97,6 +97,17 @@ exports.spawnCat = function(options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.spawnSyncCat = function(options) {
|
||||||
|
var spawnSync = require('child_process').spawnSync;
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
return spawnSync('more', [], options);
|
||||||
|
} else {
|
||||||
|
return spawnSync('cat', [], options);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.spawnPwd = function(options) {
|
exports.spawnPwd = function(options) {
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
@ -13,3 +13,7 @@ child = common.spawnPwd(options);
|
|||||||
|
|
||||||
assert.equal(child.stdout, null);
|
assert.equal(child.stdout, null);
|
||||||
assert.equal(child.stderr, null);
|
assert.equal(child.stderr, null);
|
||||||
|
|
||||||
|
options = {stdio: 'ignore'};
|
||||||
|
child = common.spawnSyncCat(options);
|
||||||
|
assert.deepEqual(options, {stdio: 'ignore'});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user