1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #2605 from johanneskropf/patch-1

use bash as shell for exec command if on linux
This commit is contained in:
Nick O'Leary 2020-06-16 14:45:34 +01:00 committed by GitHub
commit 708620f929
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ module.exports = function(RED) {
"use strict";
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var fs = require('fs');
var isUtf8 = require('is-utf8');
function ExecNode(n) {
@ -30,9 +31,12 @@ module.exports = function(RED) {
this.timer = Number(n.timer || 0)*1000;
this.activeProcesses = {};
this.oldrc = (n.oldrc || false).toString();
this.execOpt = {encoding:'binary', maxBuffer:10000000};
var node = this;
var cleanup = function(p) {
if (process.platform === 'linux' && fs.existsSync('/bin/bash')) { node.execOpt.shell = '/bin/bash'; }
var cleanup = function(p) {
node.activeProcesses[p].kill();
//node.status({fill:"red",shape:"dot",text:"timeout"});
//node.error("Exec node timeout");
@ -127,7 +131,7 @@ module.exports = function(RED) {
if (node.append.trim() !== "") { cl += " "+node.append; }
/* istanbul ignore else */
if (RED.settings.verbose) { node.log(cl); }
child = exec(cl, {encoding:'binary', maxBuffer:10000000}, function (error, stdout, stderr) {
child = exec(cl, node.execOpt, function (error, stdout, stderr) {
var msg2, msg3;
delete msg.payload;
if (stderr) {