mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Bug fix in exec node. White spaces in arguments now works (#1285)
This commit is contained in:
parent
0ee7ffb5e5
commit
adebdf36a5
@ -46,10 +46,11 @@ module.exports = function(RED) {
|
|||||||
var arg = node.cmd;
|
var arg = node.cmd;
|
||||||
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { arg += " "+msg.payload; }
|
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { arg += " "+msg.payload; }
|
||||||
if (node.append.trim() !== "") { arg += " "+node.append; }
|
if (node.append.trim() !== "") { arg += " "+node.append; }
|
||||||
// slice whole line by spaces (trying to honour quotes);
|
// slice whole line by spaces and removes any quotes since spawn can't handle them
|
||||||
arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g);
|
arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g).map((a) => {
|
||||||
|
if (/^".*"$/.test(a)) { return a.slice(1,-1)} else {return a};
|
||||||
|
});
|
||||||
var cmd = arg.shift();
|
var cmd = arg.shift();
|
||||||
if (/^".*"$/.test(cmd)) { cmd = cmd.slice(1,-1); }
|
|
||||||
/* istanbul ignore else */
|
/* istanbul ignore else */
|
||||||
if (RED.settings.verbose) { node.log(cmd+" ["+arg+"]"); }
|
if (RED.settings.verbose) { node.log(cmd+" ["+arg+"]"); }
|
||||||
child = spawn(cmd,arg);
|
child = spawn(cmd,arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user