On Jan 8, 4:41 pm, thefed [email protected] wrote:
But wouldn’t that affect the program cmd, because it is having
something passed to it?
No. This code
is running cmd with no arguments. The second occurrence of “cmd” is
what is actually passed in to the process as its program name
(available to C programs via argv in main(), for example).
So with the two-item list, there is no shell interpretation. To add
exec([cmd, cmd], arg, arg)
but that is the same as
exec(cmd, arg, arg)
simply because once you have at least two arguments to “exec”, it
behaves in the no-shell fashion anyhow.
One could “trick” a program by running
exec([cmd, “string”], arg, arg)
and the program would execute, but see “string” as how it was invoked.
This confuses some applications, but is possible.