Interpolation fixes for PERL5LIB, improve --bootstrap handling
[p5sagit/local-lib.git] / lib / local / lib.pm
index d60f3c7..3fa7546 100644 (file)
@@ -11,7 +11,7 @@ use File::Path ();
 use Carp ();
 use Config;
 
-our $VERSION = '1.000000'; # 1.0.0
+our $VERSION = '1.001000'; # 1.1.0
 
 sub import {
   my ($class, $path) = @_;
@@ -195,12 +195,12 @@ sub ensure_dir_structure_for {
   }
 }
 
-sub INTERPOLATE_PATH () { 1 }
-sub LITERAL_PATH     () { 0 }
+sub INTERPOLATE_ENV () { 1 }
+sub LITERAL_ENV     () { 0 }
 
 sub print_environment_vars_for {
   my ($class, $path) = @_;
-  my @envs = $class->build_environment_vars_for($path, LITERAL_PATH);
+  my @envs = $class->build_environment_vars_for($path, LITERAL_ENV);
   my $out = '';
 
   # rather basic csh detection, goes on the assumption that something won't
@@ -215,12 +215,9 @@ sub print_environment_vars_for {
   }
   my $shelltype = do {
       local $_ = $shellbin;
-      if(/csh/)
-      {
+      if(/csh/) {
           'csh'
-      }
-      else
-      {
+      } else {
           'bourne'
       }
   };
@@ -250,7 +247,7 @@ sub build_csh_env_declaration {
 
 sub setup_env_hash_for {
   my ($class, $path) = @_;
-  my %envs = $class->build_environment_vars_for($path, INTERPOLATE_PATH);
+  my %envs = $class->build_environment_vars_for($path, INTERPOLATE_ENV);
   @ENV{keys %envs} = values %envs;
 }
 
@@ -262,10 +259,15 @@ sub build_environment_vars_for {
     PERL5LIB => join(':',
                   $class->install_base_perl_path($path),
                   $class->install_base_arch_path($path),
+                  ($ENV{PERL5LIB} ?
+                    ($interpolate == INTERPOLATE_ENV
+                      ? ($ENV{PERL5LIB})
+                      : ('$PERL5LIB'))
+                    : ())
                 ),
     PATH => join(':',
               $class->install_base_bin_path($path),
-              ($interpolate == INTERPOLATE_PATH
+              ($interpolate == INTERPOLATE_ENV
                 ? $ENV{PATH}
                 : '$PATH')
              ),
@@ -312,13 +314,15 @@ From the shell -
 
 To bootstrap if you don't have local::lib itself installed -
 
-  $ perl -MCPAN -eshell # you only need to do this if you don't have a ~/.cpan
-  cpan> exit
   <download local::lib tarball from CPAN, unpack and cd into dir>
+
   $ perl Makefile.PL --bootstrap
   $ make test && make install
+
   $ echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc
+
   # Or for C shells...
+
   $ /bin/csh
   % echo $SHELL
   /bin/csh
@@ -394,6 +398,11 @@ Matt S Trout <mst@shadowcat.co.uk> http://www.shadowcat.co.uk/
 
 auto_install fixes kindly sponsored by http://www.takkle.com/
 
+=head1 CONTRIBUTORS
+
+Patches to correctly output commands for csh style shells, as well as some
+documentation additions, contributed by Christopher Nehren <apeiron@cpan.org>.
+
 =head1 LICENSE
 
 This library is free software under the same license as perl itself