Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl String::ShellQuote:我什么时候需要'shell_quote'?_Perl_Shell_System_Argument Passing - Fatal编程技术网

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
的参数是带空格的单个文件名