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

Let exec node (spawn) handle commands with spaces in path

This commit is contained in:
Dave Conway-Jones 2017-01-06 09:55:52 +00:00
parent 555f96cfaf
commit 08b11addec
2 changed files with 2 additions and 1 deletions

View File

@ -53,7 +53,7 @@
(on the 3rd output).</p> (on the 3rd output).</p>
<p>The optional append gets added to the command after <code>msg.payload</code> - so you can do <p>The optional append gets added to the command after <code>msg.payload</code> - so you can do
things like pipe the result to another command.</p> things like pipe the result to another command.</p>
<p>Parameters with spaces should be enclosed in quotes - <i>"This is a single parameter"</i></p> <p>Commands or parameters with spaces should be enclosed in quotes - <i>"This is a single parameter"</i></p>
<p>If stdout is binary a <i>buffer</i> is returned - otherwise returns a <i>string</i>.</p> <p>If stdout is binary a <i>buffer</i> is returned - otherwise returns a <i>string</i>.</p>
<p>The blue status icon will be visible while the node is active.</p> <p>The blue status icon will be visible while the node is active.</p>
<p>If running a Python app you may need to use the <code>-u</code> parameter to stop the output being buffered.</p> <p>If running a Python app you may need to use the <code>-u</code> parameter to stop the output being buffered.</p>

View File

@ -49,6 +49,7 @@ module.exports = function(RED) {
// slice whole line by spaces (trying to honour quotes); // slice whole line by spaces (trying to honour quotes);
arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g); arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g);
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);