X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Flocal%2Flib.pm;h=ee0bbd3bf027b02f8c75ec6c3bcf1917a3d50776;hb=4de8082430a08b7365387abd7d42830d53dac659;hp=545098e48530e5079db9b77a91d93771cf1c6dec;hpb=e322149ff77f5c6255286f89ddfcbefe62b331a2;p=p5sagit%2Flocal-lib.git diff --git a/lib/local/lib.pm b/lib/local/lib.pm index 545098e..ee0bbd3 100644 --- a/lib/local/lib.pm +++ b/lib/local/lib.pm @@ -11,7 +11,7 @@ use File::Path (); use Carp (); use Config; -our $VERSION = '1.006007'; # 1.6.7 +our $VERSION = '1.007000'; # 1.7.0 our @KNOWN_FLAGS = qw(--self-contained); @@ -230,16 +230,7 @@ sub ensure_dir_structure_for { 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_ENV); - my $out = ''; - - # rather basic csh detection, goes on the assumption that something won't - # call itself csh unless it really is. also, default to bourne in the - # pathological situation where a user doesn't have $ENV{SHELL} defined. - # note also that shells with funny names, like zoid, are assumed to be - # bourne. +sub guess_shelltype { my $shellbin = 'sh'; if(defined $ENV{'SHELL'}) { my @shell_bin_path_parts = File::Spec->splitpath($ENV{'SHELL'}); @@ -271,6 +262,21 @@ sub print_environment_vars_for { } }; } + return $shelltype; +} + +sub print_environment_vars_for { + my ($class, $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 + # call itself csh unless it really is. also, default to bourne in the + # pathological situation where a user doesn't have $ENV{SHELL} defined. + # note also that shells with funny names, like zoid, are assumed to be + # bourne. + + my $shelltype = $class->guess_shelltype; while (@envs) { my ($name, $value) = (shift(@envs), shift(@envs)); @@ -310,6 +316,7 @@ sub setup_env_hash_for { sub build_environment_vars_for { my ($class, $path, $interpolate) = @_; return ( + PERL_LOCAL_LIB_ROOT => $path, PERL_MB_OPT => "--install_base ${path}", PERL_MM_OPT => "INSTALL_BASE=${path}", PERL5LIB => join($Config{path_sep}, @@ -368,9 +375,9 @@ From the shell - # Just print out useful shell commands $ perl -Mlocal::lib export PERL_MB_OPT='--install_base /home/username/perl5' - export PERL_MM_OPT='INSTALL_BASE=/home/username/perl' - export PERL5LIB='/home/username/perl/lib/perl5:/home/username/perl/lib/perl5/i386-linux' - export PATH="/home/username/perl/bin:$PATH" + export PERL_MM_OPT='INSTALL_BASE=/home/username/perl5' + export PERL5LIB='/home/username/perl5/lib/perl5/i386-linux:/home/username/perl5/lib/perl5' + export PATH="/home/username/perl5/bin:$PATH" =head2 The bootstrapping technique