From: t0m Date: Fri, 12 Jun 2009 08:22:13 +0000 (+0000) Subject: grink's fixes for --self-contained X-Git-Tag: 1.006009~74 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4892f2b605119b29dfe1d4cad4da89d50b8c6de;p=p5sagit%2Flocal-lib.git grink's fixes for --self-contained git-svn-id: http://dev.catalyst.perl.org/repos/bast/local-lib/1.000/trunk@6646 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/Changes b/Changes index 2efe8eb..d6b020b 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for local::lib + - Put PERL5LIB first, so it'll be favored over privlibexp and + archlibexp when self contained. + - Automatically untaint @INC + - Prevent @INC from growing when you have multiple scripts using + --self-contained called from inside one another. + 1.004001 2009-05-21 - Clean up CPAN.pm's environment variable the same way we do for CPANPLUS. Add an example program showing local::lib employed diff --git a/lib/local/lib.pm b/lib/local/lib.pm index 6c629c1..1f7a33a 100644 --- a/lib/local/lib.pm +++ b/lib/local/lib.pm @@ -16,6 +16,9 @@ our $VERSION = '1.004001'; # 1.4.1 sub import { my ($class, @args) = @_; + # Remember what PERL5LIB was when we started + my $perl5lib = $ENV{PERL5LIB}; + # The path is required, but last in the list, so we pop, not shift here. my $path = pop @args; $path = $class->resolve_path($path); @@ -37,12 +40,17 @@ DEATH } if ($flag eq '--self-contained') { # The only directories that remain are those that we just defined and those where core modules are stored. - @INC = ($Config::Config{privlibexp}, $Config::Config{archlibexp}, split ':', $ENV{PERL5LIB}); + # We put PERL5LIB first, so it'll be favored over privlibexp and archlibexp + @INC = ( $class->install_base_perl_path($path), $class->install_base_arch_path($path), split( ':', $perl5lib ), $Config::Config{privlibexp}, $Config::Config{archlibexp} ); + + # We explicitly set PERL5LIB here (back to what it was originally) to prevent @INC from growing with each invocation + $ENV{PERL5LIB} = $perl5lib; } elsif (defined $flag) { die "unrecognized import argument: $flag"; } + m/(.*)/ and $_ = $1 for @INC; # Untaint @INC } sub pipeline;