3 ms·
I handle that with two variadic functions (arguments are stringified and spaced): template <typename... A> int shell(A... arguments) template <typename
by vmorgulis 11y ago
I handle that with two variadic functions (arguments are stringified and spaced):
template <typename... A> int shell(A... arguments)
template <typename... A> string execute(A... arguments)
shell() does a system() and returns the exit code (so the output is echoed in the terminal).
execute() launch a process with popen() and returns the captured steam as a string.
About capture of stderr with fork(), I like the way it's done in Node.js: https://nodejs.org/api/child_process.html https://nodejs.org/api/child_process.html
shell: https://github.com/vmorgulys/sandbox/blob/master/stackcity/source/core/i.function.shell.cpp https://github.com/vmorgulys/sandbox/blob/master/stackcity/s...
pfile: https://github.com/vmorgulys/sandbox/blob/master/stackcity/source/core/class.pfile.cpp https://github.com/vmorgulys/sandbox/blob/master/stackcity/s...