- Fix Win32 / Cygwin detection (emazep).
[p5sagit/local-lib.git] / lib / local / lib.pm
index 1054bdc..7ceb993 100644 (file)
@@ -11,7 +11,7 @@ use File::Path ();
 use Carp ();
 use Config;
 
-our $VERSION = '1.004002'; # 1.4.2
+our $VERSION = '1.004004'; # 1.4.4
 
 sub import {
   my ($class, @args) = @_;
@@ -41,8 +41,8 @@ DEATH
   if ($flag eq '--self-contained') {
     # The only directories that remain are those that we just defined and those where core modules are stored. 
     # We put PERL5LIB first, so it'll be favored over privlibexp and archlibexp
-    @INC = ($Config::Config{privlibexp}, $Config::Config{archlibexp}, split $Config{path_sep}, $ENV{PERL5LIB});
-    @INC = (
+    my %seen;
+    @INC = grep { ! $seen{$_}++ } (
       $class->install_base_perl_path($path),
       $class->install_base_arch_path($path),
       split( $Config{path_sep}, $perl5lib ),
@@ -50,8 +50,9 @@ DEATH
       $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;
+    # We explicitly set PERL5LIB here to the above de-duped list to prevent
+    # @INC from growing with each invocation 
+    $ENV{PERL5LIB} = join( $Config{path_sep}, @INC );
   }
   elsif (defined $flag) {
       die "unrecognized import argument: $flag";
@@ -271,8 +272,8 @@ sub print_environment_vars_for {
       }
   };
 
-  # Win32 uses this variable.
-  if (defined $ENV{'COMSPEC'}) {
+  # Both Win32 and Cygwin have $ENV{COMSPEC} set.
+  if (defined $ENV{'COMSPEC'} && $^O ne 'cygwin') {
       my @shell_bin_path_parts = File::Spec->splitpath($ENV{'COMSPEC'});
       $shellbin = $shell_bin_path_parts[-1];
          $shelltype = do {