Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

find_perl_interpreter now return an array

This is necessary for operation under core, where the correct invocation
is something like «./perl -Ilib …»
  • Loading branch information...
commit 87695f279156e01f8bbb9a6caffaae7bee335396 1 parent edbca7b
Leon Timmermans authored
Showing with 17 additions and 18 deletions.
  1. +1 −0  Changes
  2. +16 −18 lib/Devel/FindPerl.pm
1  Changes
View
@@ -1,6 +1,7 @@
Revision history for Devel-FindPerl
{{$NEXT}}
+ find_perl_interpreter now return an array
0.008 2013-11-01 17:48:53 Europe/Amsterdam
Always empty $ENV{PATH} before open2
34 lib/Devel/FindPerl.pm
View
@@ -18,7 +18,8 @@ my %perl_for;
sub find_perl_interpreter {
my $config = shift || 'Devel::FindPerl::Config';
my $key = $config->can('serialize') ? $config->serialize : '';
- return $perl_for{$key} ||= _discover_perl_interpreter($config);
+ $perl_for{$key} ||= _discover_perl_interpreter($config);
+ return wantarray ? @{ $perl_for{$key} } : $perl_for{$key}[0];
}
sub _discover_perl_interpreter {
@@ -30,7 +31,7 @@ sub _discover_perl_interpreter {
my @potential_perls;
# Try 1, Check $^X for absolute path
- push @potential_perls, file_name_is_absolute($^X) ? $^X : rel2abs($^X) unless tainted($^X);
+ push @potential_perls, [ file_name_is_absolute($^X) ? $^X : rel2abs($^X) ] unless tainted($^X);
# Try 2, Last ditch effort: These two option use hackery to try to locate
# a suitable perl. The hack varies depending on whether we are running
@@ -43,7 +44,13 @@ sub _discover_perl_interpreter {
my $perl_src = realpath(_perl_src());
if (defined($perl_src) && length($perl_src)) {
my $uninstperl = rel2abs(catfile($perl_src, $perl_basename));
- push @potential_perls, $uninstperl;
+ # When run from the perl core, @INC will include the directories
+ # where perl is yet to be installed. We need to reference the
+ # absolute path within the source distribution where it can find
+ # it's Config.pm This also prevents us from picking up a Config.pm
+ # from a different configuration that happens to be already
+ # installed in @INC.
+ push @potential_perls, [ $uninstperl, '-I' . catdir(dirname($^X), 'lib') ];
}
}
else {
@@ -51,8 +58,8 @@ sub _discover_perl_interpreter {
# PATH. We do not want to do either if we are running from an
# uninstalled perl in a perl source tree.
- push @potential_perls, $config->get('perlpath');
- push @potential_perls, map { catfile($_, $perl_basename) } grep { !tainted($_) } path();
+ push @potential_perls, [ $config->get('perlpath') ];
+ push @potential_perls, map { [ catfile($_, $perl_basename) ] } grep { !tainted($_) } path();
}
# Now that we've enumerated the potential perls, it's time to test
@@ -60,13 +67,13 @@ sub _discover_perl_interpreter {
# absolute path of the first successful match.
my $exe = $config->get('exe_ext');
foreach my $thisperl (@potential_perls) {
- $thisperl .= $exe if length $exe and $thisperl !~ m/$exe$/i;
- return $thisperl if -f $thisperl && perl_is_same($thisperl);
+ $thisperl->[0] .= $exe if length $exe and $thisperl->[0] !~ m/$exe$/i;
+ return $thisperl if -f $thisperl->[0] && perl_is_same(@{$thisperl});
}
# We've tried all alternatives, and didn't find a perl that matches
# our configuration. Throw an exception, and list alternatives we tried.
- my @paths = map { dirname($_) } @potential_perls;
+ my @paths = map { dirname($_->[0]) } @potential_perls;
die "Can't locate the perl binary used to run this script in (@paths)\n";
}
@@ -100,17 +107,8 @@ sub _perl_src {
}
sub perl_is_same {
- my $perl = shift;
+ my @cmd = @_;
- my @cmd = $perl;
-
- # When run from the perl core, @INC will include the directories
- # where perl is yet to be installed. We need to reference the
- # absolute path within the source distribution where it can find
- # it's Config.pm This also prevents us from picking up a Config.pm
- # from a different configuration that happens to be already
- # installed in @INC.
- push @cmd, '-I' . catdir(dirname($perl), 'lib') if $ENV{PERL_CORE};
push @cmd, qw(-MConfig=myconfig -e print -e myconfig);
local $ENV{PATH} = '';
Please sign in to comment.
Something went wrong with that request. Please try again.