X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FFindBin.pm;h=0dbe5506203607b4d51a2722ade5bae9d1a45e62;hb=e82b93481bc82235f35444c372503cc96abe405b;hp=b1d640421da2a6cdf0be7e724d547008f0df1b19;hpb=d0c833c6b6d161774fa9ee0c74b6748675c48591;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/FindBin.pm b/lib/FindBin.pm index b1d6404..0dbe550 100644 --- a/lib/FindBin.pm +++ b/lib/FindBin.pm @@ -24,9 +24,9 @@ Locates the full path to the script bin directory to allow the use of paths relative to the bin directory. This allows a user to setup a directory tree for some software with -directories ErootE/bin and ErootE/lib and then the above example will allow -the use of modules in the lib directory without knowing where the software -tree is installed. +directories C<< /bin >> and C<< /lib >>, and then the above +example will allow the use of modules in the lib directory without knowing +where the software tree is installed. If perl is invoked using the B<-e> option or the perl script is read from C then FindBin sets both C<$Bin> and C<$RealBin> to the current @@ -65,9 +65,10 @@ If perl is invoked as perl filename -and I does not have executable rights and a program called I -exists in the users C<$ENV{PATH}> which satisfies both B<-x> and B<-T> then FindBin -assumes that it was invoked via the C<$ENV{PATH}>. +and I does not have executable rights and a program called +I exists in the users C<$ENV{PATH}> which satisfies both B<-x> +and B<-T> then FindBin assumes that it was invoked via the +C<$ENV{PATH}>. Workaround is to invoke perl as @@ -76,7 +77,8 @@ Workaround is to invoke perl as =head1 AUTHORS FindBin is supported as part of the core perl distribution. Please send bug -reports to EFE using the perlbug program included with perl. +reports to EFE using the perlbug program +included with perl. Graham Barr EFE Nick Ing-Simmons EFE @@ -102,7 +104,15 @@ use File::Spec; %EXPORT_TAGS = (ALL => [qw($Bin $Script $RealBin $RealScript $Dir $RealDir)]); @ISA = qw(Exporter); -$VERSION = "1.45"; +$VERSION = "1.47"; + +sub cwd2 { + my $cwd = getcwd(); + # getcwd might fail if it hasn't access to the current directory. + # try harder. + defined $cwd or $cwd = cwd(); + $cwd; +} sub init { @@ -112,9 +122,8 @@ sub init if($0 eq '-e' || $0 eq '-') { # perl invoked with -e or script is on C - $Script = $RealScript = $0; - $Bin = $RealBin = getcwd(); + $Bin = $RealBin = cwd2(); } else { @@ -160,9 +169,7 @@ sub init # Ensure $script contains the complete path in case we C - my $cwd = getcwd(); - defined $cwd or $cwd = cwd(); # try harder - $script = File::Spec->catfile($cwd, $script) + $script = File::Spec->catfile(cwd2(), $script) unless File::Spec->file_name_is_absolute($script); ($Script,$Bin) = fileparse($script); @@ -181,7 +188,11 @@ sub init } # Get absolute paths to directories - $Bin = abs_path($Bin) if($Bin); + if ($Bin) { + my $BinOld = $Bin; + $Bin = abs_path($Bin); + defined $Bin or $Bin = File::Spec->canonpath($BinOld); + } $RealBin = abs_path($RealBin) if($RealBin); } } @@ -192,4 +203,3 @@ BEGIN { init } *again = \&init; 1; # Keep require happy -