mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
use bash as shell for exec command if on linux
This relates to: https://github.com/node-red/node-red/issues/2604 and https://discourse.nodered.org/t/exec-node-timeout-not-working-in-exec-mode/28040 and is a possible workaround for most issues related to kill described there. This has only been tested on linux where this change applies so it would most definitely need more testing on windows/mac and maybe linux distributions where there is no bash(?).
This commit is contained in:
parent
c6c42740c5
commit
06adf3d346
@ -18,6 +18,7 @@ module.exports = function(RED) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
|
var fs = require('fs');
|
||||||
var isUtf8 = require('is-utf8');
|
var isUtf8 = require('is-utf8');
|
||||||
|
|
||||||
function ExecNode(n) {
|
function ExecNode(n) {
|
||||||
@ -122,12 +123,14 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
var execOpt = {encoding:'binary', maxBuffer:10000000};
|
||||||
|
if (process.platform === 'linux' && fs.existsSync('/bin/bash')) { execOpt.shell = '/bin/bash'; }
|
||||||
var cl = node.cmd;
|
var cl = node.cmd;
|
||||||
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { cl += " "+msg.payload; }
|
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { cl += " "+msg.payload; }
|
||||||
if (node.append.trim() !== "") { cl += " "+node.append; }
|
if (node.append.trim() !== "") { cl += " "+node.append; }
|
||||||
/* istanbul ignore else */
|
/* istanbul ignore else */
|
||||||
if (RED.settings.verbose) { node.log(cl); }
|
if (RED.settings.verbose) { node.log(cl); }
|
||||||
child = exec(cl, {encoding:'binary', maxBuffer:10000000}, function (error, stdout, stderr) {
|
child = exec(cl, execOpt, function (error, stdout, stderr) {
|
||||||
var msg2, msg3;
|
var msg2, msg3;
|
||||||
delete msg.payload;
|
delete msg.payload;
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user