note
ikegami
<p>Yes and no.
<ul>
<li><p>No, <c>system</c> does quote (in ActivePerl, at least).
<c>
@cmd = ( 'echo', 'identifier', 'a string', '"pre quoted"' );
system(@cmd); # identifier "a string" "pre quoted"
$cmd = "@cmd";
system($cmd); # identifier a string "pre quoted"
</c>
<li>
<p>Yes, sending the command as a string instead of a list of arguments is a good idea in Windows. In Windows, command line parsing is done by the child. That means every program has its own mechanism to quote and escape its parameters (<a href="#star605733">*</a>). In turn, that means that <c>system</c> (or the underlying library) must guess at how the child wants its arguments quoted and escaped.
<p>Avoid the guessing if possible and provide to the child what the child will receive.
</ul>
<p><a name="star605733">*</a> — If any! When quoting is supported, it's usually double quotes. As for an escaping mechanism, I don't remember ever seeing one, so good luck trying to pass a double quote to a program...
605706
605727