in reply to Re^5: quoting issue with system command (Win32)
in thread quoting issue with system command
Maybe your echo is different.
Ah, right, that seems to be the issue — apparently, my echo is swallowing the quotes... With $^X, perl is being passed the arguments as expected:
c:\>perl t.pl -p blastn -d value of $hu_seq value of $hd_seq -i value of $contig -o value of $alignment
So far so good. OTOH, the reason I had tried this again at all was that I dimly remembered having had "issues" with the multi-argument form of system() recently (on Windows): I had to pass a double-quoted value (a filename with spaces) through to another script (outside of my control), which itself was then calling system(). Due to the way the script was written, one level of quoting was being removed, which is why the argument itself needed to contain double quotes around the filename.
I had tried something like this
my $outfile = '\"c:\Documents and Settings\foo\my file\"'; my @command = ( $^X, '-leprint for @ARGV', '--', '-o', $outfile ); 0 == system @command or die "system @command failed: $?";
expecting that $outfile would automatically get an outer pair of double quotes added around the specified value. However, it didn't, producing
c:\>perl t.pl -o "c:\Documents and Settings\foo\my file"
while the corresponding one-argument form works fine
my $outfile = '\"c:\Documents and Settings\foo\my file\"'; my $command = qq($^X -le"print for \@ARGV" -- -o "$outfile"); 0 == system $command or die "system $command failed: $?"; __END__ -o "c:\Documents and Settings\foo\my file"
Seems kind of inconsequent to me that with the multi-argument form, you still have to fiddle with the quoting yourself, i.e. add extra outer double quotes like this
my $outfile = '"\"c:\Documents and Settings\foo\my file\""';
to get the correct behavior. Why isn't this being done by Perl, when other values are apparently being quoted properly?
|
|---|