shell: exec encoding is utf8 by default and no shell
explicitly mark calls that require the shell
This commit is contained in:
+8
-4
@@ -19,7 +19,7 @@ exports = module.exports = {
|
||||
|
||||
const SUDO = '/usr/bin/sudo';
|
||||
|
||||
// default encoding utf8, shell, handles input. full command
|
||||
// default encoding utf8, shell, handles input, full command
|
||||
function exec(tag, cmd, options, callback) {
|
||||
assert.strictEqual(typeof tag, 'string');
|
||||
assert.strictEqual(typeof cmd, 'string');
|
||||
@@ -28,8 +28,10 @@ function exec(tag, cmd, options, callback) {
|
||||
|
||||
debug(`${tag} exec: ${cmd}`);
|
||||
|
||||
const execOptions = Object.assign({ encoding: 'utf8', shell: false }, options);
|
||||
|
||||
// https://github.com/nodejs/node/issues/25231
|
||||
const cp = child_process.exec(cmd, options, function (error, stdout, stderr) {
|
||||
const cp = child_process.exec(cmd, execOptions, function (error, stdout, stderr) {
|
||||
let e = null;
|
||||
if (error) {
|
||||
e = new BoxError(BoxError.SHELL_ERROR, `${tag} errored with code ${error.code} message ${error.message}`);
|
||||
@@ -48,7 +50,7 @@ function exec(tag, cmd, options, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
// no shell, utf8 encoding, separate args
|
||||
// default encoding utf8, no shell, separate args
|
||||
function execFile(tag, file, args, options, callback) {
|
||||
assert.strictEqual(typeof tag, 'string');
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
@@ -58,8 +60,10 @@ function execFile(tag, file, args, options, callback) {
|
||||
|
||||
debug(`${tag} exec: ${file}`);
|
||||
|
||||
const execOptions = Object.assign({ encoding: 'utf8', shell: false }, options);
|
||||
|
||||
// https://github.com/nodejs/node/issues/25231
|
||||
const cp = child_process.execFile(file, args, options, function (error, stdout, stderr) {
|
||||
const cp = child_process.execFile(file, args, execOptions, function (error, stdout, stderr) {
|
||||
let e = null;
|
||||
if (error) {
|
||||
e = new BoxError(BoxError.SHELL_ERROR, `${tag} errored with code ${error.code} message ${error.message}`);
|
||||
|
||||
Reference in New Issue
Block a user