Subject: | Problems when path to script/module contains whitespaces |
Date: | Tue, 20 Jan 2009 20:14:59 +0100 |
To: | bug-Test-Strict [...] rt.cpan.org |
From: | Renée Bäcker <perl [...] renee-baecker.de> |
Hi,
I had some problems with this module as this calls "perl -c $script"
(e.g. perl -c C:\Test and Test\script.pl) if the path to the script
contains whitespaces perl complains that there is no perl script "and".
Perl can't know that the path contains whitespaces. The same with the
directories that are added to @INC via the -I switch.
Attached is a patch that fixes these issues.
Cheers,
Renee
--- Strict.pm.orig 2009-01-20 20:09:20.000000000 +0100
+++ Strict.pm 2009-01-20 19:52:38.000000000 +0100
@@ -165,13 +165,13 @@
return;
}
- my $inc = join(' -I ', @INC) || '';
+ my $inc = join(' -I ', map{ "\"$_\""}@INC) || '';
$inc = "-I $inc" if $inc;
$file = _untaint($file);
my $perl_bin = _untaint($PERL);
local $ENV{PATH} = _untaint($ENV{PATH}) if $ENV{PATH};
- my $eval = `$perl_bin $inc -c $file 2>&1`;
+ my $eval = `$perl_bin $inc -c \"$file\" 2>&1`;
$file = quotemeta($file);
my $ok = $eval =~ qr!$file syntax OK!ms;
$Test->ok($ok, $test_txt);
@@ -340,7 +340,7 @@
}
foreach my $file ( @all_files ) {
$file = _untaint($file);
- `$perl_bin -MDevel::Cover=$DEVEL_COVER_OPTIONS $file 2>&1 > /dev/null`;
+ `$perl_bin -MDevel::Cover=$DEVEL_COVER_OPTIONS "$file" 2>&1 > /dev/null`;
$Test->ok(! $?, "Coverage captured from $file" );
}
$Test->ok(my $cover = `$cover_bin 2>/dev/null`, "Got cover");