shell quoting unified


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.)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]