I have found a difference in how my node.js shell script works in Windows vs Linux. I have a string of commands that are synchronously executed using the child_process library.
var cmd = `echo 'hello'
echo 'Stack'
echo 'Overflow'`
var exec = require('child_process').execSync;
var options = {
encoding: 'utf8'
};
console.log(exec(cmd, options));
In Linux
This executes all 3 echo
statements and outputs as I expect it to.
hello
Stack
Overflow
In Windows
Whereas in Windows, I don't know if it executes 3 times or not. All I do know is that only the first echo
command is outputted.
hello
Why am I seeing this difference and can I fix it so that the Windows script outputs similar to the way it does on Linux?