- Version: 5.10.1, 6.1.0
- Platform: Win 10 x64
- Subsystem:
Using the child_process.spawnSync() function call, the args I pass are being cut if they contain an & in them. Here's my snippet:
var child=require('child_process');
var args =[];
args [0]="a";
args [1]="b";
args [2]="\"a&b\"";
var r = child.spawnSync("c:/temp/test.cmd", args);
r.stdout.toString();
Here's the output:
> var child=require('child_process');
undefined
> var args =[];
undefined
> args [0]="a";
'a'
> args [1]="b";
'b'
> args [2]="\"a&b\"";
'"a&b"'
> var r = child.spawnSync("c:/temp/test.cmd", args);
undefined
> r.stdout.toString();
'\r\nC:\\Program Files\\nodejs6.1.0>echo args=a b "\\"a \r\nargs=a b "\\"a\r\n'
Notice that the 3rd arg, "a&b" is passed only as "a
here's the contents of test.cmd:
And here's the same output from commandline:
C:\temp>test a b "a&b"
C:\temp>echo args=a b "a&b"
args=a b "a&b"
[edit: fixed formatting - bnoordhuis]
Using the child_process.spawnSync() function call, the args I pass are being cut if they contain an & in them. Here's my snippet:
Here's the output:
Notice that the 3rd arg, "a&b" is passed only as "a
here's the contents of test.cmd:
And here's the same output from commandline:
[edit: fixed formatting - bnoordhuis]