From e50d04077be99af528fb404464fb8641abb2fa36 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 20 Jun 2016 19:28:59 +0100 Subject: [PATCH] Let exec node handle 0 as well as "0" --- nodes/core/core/75-exec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nodes/core/core/75-exec.js b/nodes/core/core/75-exec.js index da03bf61a..6f2ac9393 100644 --- a/nodes/core/core/75-exec.js +++ b/nodes/core/core/75-exec.js @@ -29,6 +29,7 @@ module.exports = function(RED) { this.useSpawn = n.useSpawn; this.timer = Number(n.timer || 0)*1000; this.activeProcesses = {}; + var node = this; var cleanup = function(p) { //console.log("CLEANUP!!!",p); @@ -37,7 +38,6 @@ module.exports = function(RED) { node.error("Exec node timeout"); } - var node = this; this.on("input", function(msg) { var child; node.status({fill:"blue",shape:"dot",text:" "}); @@ -45,8 +45,8 @@ module.exports = function(RED) { // make the extra args into an array // then prepend with the msg.payload var arg = node.cmd; - if (node.addpay) { arg += " "+msg.payload; } - arg += " "+node.append; + if ((node.addpay === true) && msg.hasOwnProperty("payload")) { arg += " "+msg.payload; } + if (node.append.trim() !== "") { arg += " "+node.append; } // slice whole line by spaces (trying to honour quotes); arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g); var cmd = arg.shift(); @@ -88,7 +88,7 @@ module.exports = function(RED) { } else { var cl = node.cmd; - if ((node.addpay === true) && ((msg.payload || "").toString().trim() !== "")) { cl += " "+msg.payload; } + if ((node.addpay === true) && msg.hasOwnProperty("payload")) { cl += " "+msg.payload; } if (node.append.trim() !== "") { cl += " "+node.append; } /* istanbul ignore else */ if (RED.settings.verbose) { node.log(cl); }