Perl String::ShellQuote:我什么时候需要'shell_quote'?
当我以这种方式将参数传递给Perl String::ShellQuote:我什么时候需要'shell_quote'?,perl,shell,system,argument-passing,Perl,Shell,System,Argument Passing,当我以这种方式将参数传递给system时,使用shell_qoute有意义吗 #!/usr/bin/env perl use warnings; use 5.012; use String::ShellQuote qw(shell_quote); my $file = shift; my $argument = shift; $file = shell_quote $file; $argument = shell_quote $argument; system( 'some_command
system
时,使用shell_qoute
有意义吗
#!/usr/bin/env perl
use warnings;
use 5.012;
use String::ShellQuote qw(shell_quote);
my $file = shift;
my $argument = shift;
$file = shell_quote $file;
$argument = shell_quote $argument;
system( 'some_command', '--verbose', '-o', $file, $argument );
不,没有。如果调用
系统
作为
system LIST
然后它不会调用shell。Shell元字符没有特殊意义。所以你不能引用你的论点,否则它会给出错误的结果
如果system
作为
system SCALAR
其中标量可能类似于带空格的ls文件名
,而ls
的参数是带空格的单个文件名