Sujet : Re: perl test
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : misc.test comp.lang.miscDate : 08. Sep 2024, 07:38:17
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbjgop$1r6qd$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Pan/0.160 (Toresk; )
On Sat, 7 Sep 2024 23:11:41 +0000, Retro Guy wrote:
On Sat, 7 Sep 2024 22:59:41 +0000, Lawrence D'Oliveiro wrote:
If you want to pass arguments to an external program, don’t bother
going through a shell if you can help it. Invoke the program and pass
the command-line arguments directly, then you don’t have to worry about
shell specials.
That would be my preference, but I'm not sure how to do that from Perl.
From the perlfunc(1) man page:
system LIST
system PROGRAM LIST
Does exactly the same thing as "exec", except that a fork
is done first and the parent process waits for the child
process to exit. Note that argument processing varies
depending on the number of arguments. If there is more than
one argument in LIST, or if LIST is an array with more than
one value, starts the program given by the first element of
the list with arguments given by the rest of the list. If
there is only one scalar argument, the argument is checked
for shell metacharacters, and if there are any, the entire
argument is passed to the system's command shell for
parsing (this is "/bin/sh -c" on Unix platforms, but varies
on other platforms). If there are no shell metacharacters
in the argument, it is split into words and passed directly
to "execvp", which is more efficient.