| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#line 1 |
|
2
|
|
|
|
|
|
|
# FindBin.pm |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved. |
|
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
|
6
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#line 92 |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package FindBin; |
|
11
|
|
|
|
|
|
|
use Carp; |
|
12
|
|
|
|
|
|
|
require 5.000; |
|
13
|
|
|
|
|
|
|
require Exporter; |
|
14
|
|
|
|
|
|
|
use Cwd qw(getcwd cwd abs_path); |
|
15
|
|
|
|
|
|
|
use Config; |
|
16
|
|
|
|
|
|
|
use File::Basename; |
|
17
|
|
|
|
|
|
|
use File::Spec; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
@EXPORT_OK = qw($Bin $Script $RealBin $RealScript $Dir $RealDir); |
|
20
|
|
|
|
|
|
|
%EXPORT_TAGS = (ALL => [qw($Bin $Script $RealBin $RealScript $Dir $RealDir)]); |
|
21
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$VERSION = "1.47"; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub cwd2 { |
|
26
|
|
|
|
|
|
|
my $cwd = getcwd(); |
|
27
|
|
|
|
|
|
|
# getcwd might fail if it hasn't access to the current directory. |
|
28
|
|
|
|
|
|
|
# try harder. |
|
29
|
|
|
|
|
|
|
defined $cwd or $cwd = cwd(); |
|
30
|
|
|
|
|
|
|
$cwd; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub init |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
|
|
|
|
|
|
*Dir = \$Bin; |
|
36
|
|
|
|
|
|
|
*RealDir = \$RealBin; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if($0 eq '-e' || $0 eq '-') |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
|
|
|
|
|
|
# perl invoked with -e or script is on C |
|
41
|
|
|
|
|
|
|
$Script = $RealScript = $0; |
|
42
|
|
|
|
|
|
|
$Bin = $RealBin = cwd2(); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
else |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
|
|
|
|
|
|
my $script = $0; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
if ($^O eq 'VMS') |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
|
|
|
|
|
|
($Bin,$Script) = VMS::Filespec::rmsexpand($0) =~ /(.*\])(.*)/s; |
|
51
|
|
|
|
|
|
|
($RealBin,$RealScript) = ($Bin,$Script); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
else |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
|
|
|
|
|
|
my $dosish = ($^O eq 'MSWin32' or $^O eq 'os2'); |
|
56
|
|
|
|
|
|
|
unless(($script =~ m#/# || ($dosish && $script =~ m#\\#)) |
|
57
|
|
|
|
|
|
|
&& -f $script) |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
|
|
|
|
|
|
my $dir; |
|
60
|
|
|
|
|
|
|
foreach $dir (File::Spec->path) |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
|
|
|
|
|
|
my $scr = File::Spec->catfile($dir, $script); |
|
63
|
|
|
|
|
|
|
if(-r $scr && (!$dosish || -x _)) |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
|
|
|
|
|
|
$script = $scr; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if (-f $0) |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
|
|
|
|
|
|
# $script has been found via PATH but perl could have |
|
70
|
|
|
|
|
|
|
# been invoked as 'perl file'. Do a dumb check to see |
|
71
|
|
|
|
|
|
|
# if $script is a perl program, if not then $script = $0 |
|
72
|
|
|
|
|
|
|
# |
|
73
|
|
|
|
|
|
|
# well we actually only check that it is an ASCII file |
|
74
|
|
|
|
|
|
|
# we know its executable so it is probably a script |
|
75
|
|
|
|
|
|
|
# of some sort. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$script = $0 unless(-T $script); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
last; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
croak("Cannot find current script '$0'") unless(-f $script); |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Ensure $script contains the complete path in case we C |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$script = File::Spec->catfile(cwd2(), $script) |
|
89
|
|
|
|
|
|
|
unless File::Spec->file_name_is_absolute($script); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
($Script,$Bin) = fileparse($script); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Resolve $script if it is a link |
|
94
|
2
|
|
|
2
|
|
637
|
while(1) |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
135
|
|
|
95
|
|
|
|
|
|
|
{ |
|
96
|
|
|
|
|
|
|
my $linktext = readlink($script); |
|
97
|
2
|
|
|
2
|
|
7
|
|
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
91
|
|
|
98
|
2
|
|
|
2
|
|
8
|
($RealScript,$RealBin) = fileparse($script); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
94
|
|
|
99
|
2
|
|
|
2
|
|
9
|
last unless defined $linktext; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
119
|
|
|
100
|
2
|
|
|
2
|
|
8
|
|
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
800
|
|
|
101
|
|
|
|
|
|
|
$script = (File::Spec->file_name_is_absolute($linktext)) |
|
102
|
|
|
|
|
|
|
? $linktext |
|
103
|
|
|
|
|
|
|
: File::Spec->catfile($RealBin, $linktext); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Get absolute paths to directories |
|
107
|
|
|
|
|
|
|
if ($Bin) { |
|
108
|
|
|
|
|
|
|
my $BinOld = $Bin; |
|
109
|
2
|
|
|
2
|
0
|
8
|
$Bin = abs_path($Bin); |
|
110
|
|
|
|
|
|
|
defined $Bin or $Bin = File::Spec->canonpath($BinOld); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
2
|
50
|
|
|
|
5
|
$RealBin = abs_path($RealBin) if($RealBin); |
|
113
|
2
|
|
|
|
|
35
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
BEGIN { init } |
|
118
|
2
|
|
|
2
|
0
|
4
|
|
|
119
|
2
|
|
|
|
|
2
|
*again = \&init; |
|
120
|
|
|
|
|
|
|
|
|
121
|
2
|
50
|
33
|
|
|
23
|
1; # Keep require happy |