X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=script%2Fenv;h=82565417fb1aa4f390d0d3ab5214a7376bc3621f;hb=2ac971b6f7e828ae722cc37dbceb25bf7a47160f;hp=c1d23d74a14ba6dd02904f101ab806d94bdf4f98;hpb=247fc27b588ee7b963fc552a93fd74d88857004d;p=catagits%2FGitalist.git diff --git a/script/env b/script/env index c1d23d7..8256541 100755 --- a/script/env +++ b/script/env @@ -31,21 +31,17 @@ use Carp; use lib; use FindBin; use File::Spec (); +use Cwd (); # Look up to see find Makefile.PL aka the base of the local::lib install. my $lookup; $lookup = sub { - my $dir = $_[0] || '.'; + my $dir = $_[0] || $FindBin::Bin; - my(undef, $dirbit) = File::Spec->splitpath($FindBin::Bin); - my $trydir = File::Spec->catdir($dirbit, $dir); + return '' if Cwd::abs_path($dir) eq File::Spec->rootdir; - return '' unless -d $trydir; + my $tryfile = File::Spec->catfile($dir, "Makefile.PL"); - my $tryfile = File::Spec->catfile($trydir, "Makefile.PL"); - - return $trydir if -r $tryfile; - - return $lookup->( File::Spec->catdir($trydir, File::Spec->updir) ); + return -r $tryfile ? $dir : $lookup->( File::Spec->catdir($dir, File::Spec->updir) ); }; my $basedir = $lookup->();