shell quoting unified
Roland Illig
roland.illig at gmx.de
Thu Aug 19 16:44:44 UTC 2004
Hi,
I've written a Perl function shell_quote that works fine with my current
Perl and a Perl-5.005_003 that I digged out of the depth of the internet.
sub shell_quote
{
my (@result);
foreach my $i (@_) {
my $tmp = $i;
$tmp =~ s/([^\w\/.+-])/\\$1/g;
push(@result, $tmp);
}
return wantarray ? @result : $result[0];
}
You can use it like this:
sub foofs_copyin
{
my ($archive, $filename) = shell_quote(@_);
$filename = shell_quote($filename); # double-quoted
}
The advantage over the current version is the name. It is easier
readable and it tells the reader our intention.
I'd like it to replace the current regexps.
(Sorry, I'm studying computer science with the special topic "Software
Development Methodology", so I'm kind of strict concerning these things.)
Roland
More information about the mc-devel
mailing list