Does it make sense to use shell_qoute from String::ShellQuote when I pass the arguments to system this way?
#!/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 );
No it doesn't. If you invoke system as
system LIST
then it doesn't invoke the shell. Shell meta-characters have no special meaning. So you must not quote your arguments, or else it gives the wrong results.
One needs to quote if system is invoked as
system SCALAR
where SCALAR might be something like ls file name with spaces and the argument to ls is a single file name that has spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With