4 ms·
You should use child_process.execFile or the execve equiv in your language. Shell has expansion issues but rigorous quoting helped by shellcheck make it safe.
by seniorsassycat 5y ago
You should use child_process.execFile or the execve equiv in your language. Shell has expansion issues but rigorous quoting helped by shellcheck make it safe.
And zx's `$` could make better use of tagged template literals.
Something like this, tho it isn't correct
function $(strings, ...args) {
const cmd = [];
for (const part of strings) {
cmd.push(...part.split(/\s+/));
if (args.length > 0) {
cmd.push(args.shift());
}
}
return child_process.execFile(cmd[0], cmd.slice(1));
}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...