String::ShellQuote: when do I need `shell_quote`?
argument-passing, perl, shell, system
Solution
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.
Problem
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 ); ```