Change 13524 by jhi@alpha on 2001/12/07 21:58:15

        Further tweakage to which_perl().

Affected files ...

.... //depot/perl/t/test.pl#19 edit

Differences ...

==== //depot/perl/t/test.pl#19 (text) ====
Index: perl/t/test.pl
--- perl/t/test.pl.~1~  Fri Dec  7 15:15:05 2001
+++ perl/t/test.pl      Fri Dec  7 15:15:05 2001
@@ -271,28 +271,43 @@
 
 # A somewhat safer version of the sometimes wrong $^X.
 BEGIN: {
+    my $exe;
     eval {
-        require File::Spec;
         require Config;
         Config->import;
     };
-    warn "test.pl had problems loading other modules: $@" if $@;
-}
+    if ($@) {
+       warn "test.pl had problems loading Config: $@";
+       $exe = '';
+    } else {
+       $exe = $Config{_exe};
+    }
+
+    my $Perl = $^X;
+
+    # This doesn't absolutize the path: beware of future chdirs().
+    # We could do File::Spec->abs2rel() but that does getcwd()s,
+    # which is a bit heavyweight to do here.
+
+    if ($Perl =~ /^perl\Q$exe\E$/i) {
+        eval {
+           require File::Spec;
+       };
+       if ($@) {
+           warn "test.pl had problems loading File::Spec: $@";
+       } else {
+           $Perl = File::Spec->catfile(File::Spec->curdir(), "perl$exe");
+       }
+    }
 
-# We do this at compile time before the test might have chdir'd around
-# and make sure its absolute in case they do later.
-my $Perl = $^X;
-$Perl =
-    File::Spec->rel2abs(File::Spec->catfile(File::Spec->curdir(),
-                                           "perl$Config{_exe}"))
-        if $Perl =~ /^perl\Q$Config{_exe}\E$/i;
-warn "Can't generate which_perl from $^X" unless -f $Perl;
+    warn "Can't generate which_perl from $^X" unless -f $Perl;
 
-# For subcommands to use.
-$ENV{PERLEXE} = $Perl;
+    # For subcommands to use.
+    $ENV{PERLEXE} = $Perl;
 
-sub which_perl {
-    return $Perl;
+    sub which_perl {
+       return $Perl;
+    }
 }
 
 1;
End of Patch.

Reply via email to