local/lib.pm

filter: Statementstmt 60.8% 214 / 352 Branchbran 44.8% 79 / 176 Conditioncond 37.5% 33 / 88 MC/DCmcdc 20.4% 10 / 49 Subroutinesub 73.0% 46 / 63 Podpod 62.7% 27 / 43 totaltotal 53.0% 409 / 771 CC 126 SCAR 31.2
CC
126
Cov
53%
guess_shelltype
120.7
_cwd
42.7
import
36.9
CRAP 22.6
↑ Summary lib/core/only.pm »
1 package local::lib;
2 9 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 BEGIN {
4 9 ▶ if ($ENV{RELEASE_TESTING}) {
Subroutine BEGIN: called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"RELEASE_TESTING"}) 0 9 9
5 0 require strict;
6 0 strict->import;
7 0 require warnings;
8 0 warnings->import;
9 }
10 }
11 9 ▶use Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 9 our $VERSION = '2.000_026';
14 9 $VERSION =~ tr/_//d;
15  
16 BEGIN {
17 *_WIN32 = ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'symbian')
18 9 ▶ ? sub(){1} : sub(){0};
Subroutine BEGIN: called CC=7 SCAR=27.3
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'symbian' ? : 0 9 9
Condition33%2/6
$^O eq "MSWin32" or $^O eq "NetWare" or $^O eq "symbian"
l!l&&r!l&&!r
009
$^O eq "MSWin32" or $^O eq "NetWare"
l!l&&r!l&&!r
009
MC/DC0%0/3
$^O eq "MSWin32" or $^O eq "NetWare" or $^O eq "symbian"
$^O eq "MSWin32" $^O eq "NetWare" $^O eq "symbian"
Truth table25%1/4
A or B or C
A= $^O eq "MSWin32"B= $^O eq "NetWare"C= $^O eq "symbian"
ABCresult
1XX1
01X1
0011
0000
19 # punt on these systems
20 *_USE_FSPEC = ($^O eq 'MacOS' || $^O eq 'VMS' || $INC{'File/Spec.pm'})
21 9 ▶ ? sub(){1} : sub(){0};
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MacOS' || $^O eq 'VMS' || $INC{'File/Spec.pm'} ? : 9 0 9
Condition33%2/6
$^O eq "MacOS" or $^O eq "VMS" or $INC{"File/Spec.pm"}
l!l&&r!l&&!r
090
$^O eq "MacOS" or $^O eq "VMS"
l!l&&r!l&&!r
009
MC/DC0%0/3
$^O eq "MacOS" or $^O eq "VMS" or $INC{"File/Spec.pm"}
$^O eq "MacOS" $^O eq "VMS" $INC{"File/Spec.pm"}
Truth table25%1/4
A or B or C
A= $^O eq "MacOS"B= $^O eq "VMS"C= $INC{"File/Spec.pm"}
ABCresult
1XX1
01X1
0011
0000
22 }
23 9 my $_archname = $Config::Config{archname};
24 9 my $_version = $Config::Config{version};
25 9 my @_inc_version_list = reverse split / /, $Config::Config{inc_version_list};
26 9 my $_path_sep = $Config::Config{path_sep};
27  
28 9 our $_DIR_JOIN = _WIN32 ? '\\' : '/';
29 9 ▶our $_DIR_SPLIT = (_WIN32 || $^O eq 'cygwin') ? qr{[\\/]}
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'cygwin' ? : 0 9 9
30 : qr{/};
31 9 our $_ROOT = _WIN32 ? do {
32 my $UNC = qr{[\\/]{2}[^\\/]+[\\/][^\\/]+};
33 qr{^(?:$UNC|[A-Za-z]:|)$_DIR_SPLIT};
34 } : qr{^/};
35 9 our $_PERL;
36  
37 sub _perl {
38 2 ▶ if (!$_PERL) {
Subroutine _perl: called CC=7 SCAR=31.1
Branch: 1 branch
BranchTrueFalseTotal
unless ($_PERL) 2 0 2
39 # untaint and validate
40 2 ($_PERL, my $exe) = $^X =~ /((?:.*$_DIR_SPLIT)?(.+))/;
41 2 ▶ $_PERL = 'perl'
Branch: 1 branch
BranchTrueFalseTotal
unless $exe =~ /perl/ 0 2 2
42 if $exe !~ /perl/;
43 2 ▶ if (_is_abs($_PERL)) {
Branch: 3 branches
BranchTrueFalseTotal
if (_is_abs($_PERL)) { } 2 0 2
elsif (-x $Config::Config{'perlpath'}) { } 0 0 0
elsif ($_PERL =~ /$_DIR_SPLIT/ and -x $_PERL) { } 0 0 0
44 }
45 elsif (-x $Config::Config{perlpath}) {
46 0 $_PERL = $Config::Config{perlpath};
47 }
48 ▶ elsif ($_PERL =~ $_DIR_SPLIT && -x $_PERL) {
Condition0%0/3
$_PERL =~ /$_DIR_SPLIT/ and -x $_PERL
!ll&&!rl&&r
000
MC/DC0%0/2
$_PERL =~ /$_DIR_SPLIT/ and -x $_PERL
$_PERL =~ /$_DIR_SPLIT/ -x $_PERL
Truth table0%0/3
A and B
A= $_PERL =~ /$_DIR_SPLIT/B= -x $_PERL
ABresult
0X0
100
111
49 0 $_PERL = _rel2abs($_PERL);
50 }
51 else {
52 ($_PERL) =
53 0 map { /(.*)/ }
54 0 grep { -x $_ }
55 0 map { ($_, _WIN32 ? ("$_.exe") : ()) }
56 0 map { join($_DIR_JOIN, $_, $_PERL) }
57 0 split /\Q$_path_sep\E/, $ENV{PATH};
58 }
59 }
60 2 $_PERL;
61 }
62  
63 sub _cwd {
64 0 ▶ if (my $cwd
Subroutine _cwd: not called CC=7 SCAR=37.5
Branch: 3 branches
BranchTrueFalseTotal
if (my $cwd = defined &Cwd::sys_cwd ? \&Cwd::sys_cwd : (defined &Cwd::cwd ? \&Cwd::cwd : undef)) 0 0 0
defined &Cwd::sys_cwd ? : 0 0 0
defined &Cwd::cwd ? : 0 0 0
65 = defined &Cwd::sys_cwd ? \&Cwd::sys_cwd
66 : defined &Cwd::cwd ? \&Cwd::cwd
67 : undef
68 ) {
69 9 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
70 0 *_cwd = $cwd;
71 0 goto &$cwd;
72 }
73 0 my $drive = shift;
74 0 return Win32::GetCwd()
75 if _WIN32 && defined &Win32::GetCwd && !$drive;
76 0 local @ENV{qw(PATH IFS CDPATH ENV BASH_ENV)};
77 0 ▶ my $cmd = $drive ? "eval { Cwd::getdcwd(q($drive)) }"
Branch: 1 branch
BranchTrueFalseTotal
$drive ? : 0 0 0
78 : 'getcwd';
79 0 my $perl = _perl;
80 0 my $cwd = `"$perl" -MCwd -le "print $cmd"`;
81 0 chomp $cwd;
82 0 ▶ if (!length $cwd && $drive) {
Branch: 1 branch
BranchTrueFalseTotal
if (not length $cwd and $drive) 0 0 0
Condition0%0/3
not length $cwd and $drive
!ll&&!rl&&r
000
MC/DC0%0/2
not length $cwd and $drive
not length $cwd $drive
Truth table0%0/3
not(A) and B
A= not length $cwdB= $drive
ABresult
0X0
100
111
83 0 $cwd = $drive;
84 }
85 0 $cwd =~ s/$_DIR_SPLIT?$/$_DIR_JOIN/;
86 0 $cwd;
87 }
88  
89 sub _catdir {
90 270 ▶ if (_USE_FSPEC) {
Subroutine _catdir: called CC=1 SCAR=0.0
91 270 require File::Spec;
92 270 File::Spec->catdir(@_);
93 }
94 else {
95 my $dir = join($_DIR_JOIN, @_);
96 $dir =~ s{($_DIR_SPLIT)(?:\.?$_DIR_SPLIT)+}{$1}g;
97 $dir;
98 }
99 }
100  
101 sub _is_abs {
102 18 ▶ if (_USE_FSPEC) {
Subroutine _is_abs: called CC=1 SCAR=0.0
103 18 require File::Spec;
104 18 File::Spec->file_name_is_absolute($_[0]);
105 }
106 else {
107 $_[0] =~ $_ROOT;
108 }
109 }
110  
111 sub _rel2abs {
112 16 ▶ my ($dir, $base) = @_;
Subroutine _rel2abs: called CC=3 SCAR=16.5
113 16 ▶ return $dir
Branch: 1 branch
BranchTrueFalseTotal
if _is_abs($dir) 16 0 16
114 if _is_abs($dir);
115  
116 0 ▶ $base = _WIN32 && $dir =~ s/^([A-Za-z]:)// ? _cwd("$1")
Branch: 1 branch
BranchTrueFalseTotal
$base ? : 0 0 0
117 : $base ? _rel2abs($base)
118 : _cwd;
119 0 return _catdir($base, $dir);
120 }
121  
122 9 our $_DEVNULL;
123 sub _devnull {
124 0 ▶ return $_DEVNULL ||=
Subroutine _devnull: not called CC=2 SCAR=17.9
Condition0%0/3
$_DEVNULL ||= (require File::Spec, "File::Spec"->devnull)
l!l&&r!l&&!r
000
MC/DC0%0/2
$_DEVNULL ||= (require File::Spec, "File::Spec"->devnull)
$_DEVNULL (require File::Spec, "File::Spec"->devnull)
Truth table0%0/3
A ||= B
A= $_DEVNULLB= (require File::Spec, "File::Spec"->devnull)
ABresult
1X1
011
000
125 _USE_FSPEC ? (require File::Spec, File::Spec->devnull)
126 : _WIN32 ? 'nul'
127 : $^O eq 'os2' ? '/dev/nul'
128 : '/dev/null';
129 }
130  
131 sub import {
132 14 ▶ my ($class, @args) = @_;
Subroutine import: called CC=17 SCAR=36.1
133 14 ▶ if ($0 eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($0 eq "-") 0 14 14
134 0 push @args, @ARGV;
135 0 require Cwd;
136 }
137  
138 14 my @steps;
139 my %opts;
140 14 my %attr;
141 14 my $shelltype;
142  
143 14 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 15 14 29
144 15 my $arg = shift @args;
145 # check for lethal dash first to stop processing before causing problems
146 # the fancy dash is U+2212 or \xE2\x88\x92
147 15 ▶ if ($arg =~ /\xE2\x88\x92/) {
Branch: 9 branches
BranchTrueFalseTotal
if ($arg =~ /\xE2\x88\x92/) { } 0 15 15
elsif ($arg eq '--self-contained') { } 0 15 15
elsif ($arg =~ /^--deactivate(?:=(.*))?$/) { } 1 14 15
elsif ($arg eq '--deactivate-all') { } 0 14 14
elsif ($arg =~ /^--shelltype(?:=(.*))?$/) { } 0 14 14
elsif ($arg eq '--no-create') { } 1 13 14
elsif ($arg eq '--quiet') { } 0 13 13
elsif ($arg eq '--always') { } 0 13 13
elsif ($arg =~ /^--/) { } 0 13 13
148 0 die <<'DEATH';
149 WHOA THERE! It looks like you've got some fancy dashes in your commandline!
150 These are *not* the traditional -- dashes that software recognizes. You
151 probably got these by copy-pasting from the perldoc for this module as
152 rendered by a UTF8-capable formatter. This most typically happens on an OS X
153 terminal, but can happen elsewhere too. Please try again after replacing the
154 dashes with normal minus signs.
155 DEATH
156 }
157 elsif ($arg eq '--self-contained') {
158 0 die <<'DEATH';
159 FATAL: The local::lib --self-contained flag has never worked reliably and the
160 original author, Mark Stosberg, was unable or unwilling to maintain it. As
161 such, this flag has been removed from the local::lib codebase in order to
162 prevent misunderstandings and potentially broken builds. The local::lib authors
163 recommend that you look at the lib::core::only module shipped with this
164 distribution in order to create a more robust environment that is equivalent to
165 what --self-contained provided (although quite possibly not what you originally
166 thought it provided due to the poor quality of the documentation, for which we
167 apologise).
168 DEATH
169 }
170 elsif( $arg =~ /^--deactivate(?:=(.*))?$/ ) {
171 1 ▶ my $path = defined $1 ? $1 : shift @args;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 1 1
172 1 push @steps, ['deactivate', $path];
173 }
174 elsif ( $arg eq '--deactivate-all' ) {
175 0 push @steps, ['deactivate_all'];
176 }
177 elsif ( $arg =~ /^--shelltype(?:=(.*))?$/ ) {
178 0 ▶ $shelltype = defined $1 ? $1 : shift @args;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
179 }
180 elsif ( $arg eq '--no-create' ) {
181 1 $opts{no_create} = 1;
182 }
183 elsif ( $arg eq '--quiet' ) {
184 0 $attr{quiet} = 1;
185 }
186 elsif ( $arg eq '--always' ) {
187 0 $attr{always} = 1;
188 }
189 elsif ( $arg =~ /^--/ ) {
190 0 die "Unknown import argument: $arg";
191 }
192 else {
193 13 push @steps, ['activate', $arg, \%opts];
194 }
195 }
196 14 ▶ if (!@steps) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@steps) 0 14 14
197 0 push @steps, ['activate', undef, \%opts];
198 }
199  
200 14 my $self = $class->new(%attr);
201  
202 14 for (@steps) {
203 14 my ($method, @args) = @$_;
204 14 $self = $self->$method(@args);
205 }
206  
207 14 ▶ if ($0 eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($0 eq '-') { } 0 14 14
208 0 print $self->environment_vars_string($shelltype);
209 0 exit 0;
210 }
211 else {
212 14 $self->setup_local_lib;
213 }
214 }
215  
216 sub new {
217 20 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
218 20 bless {@_}, $class;
219 }
220  
221 sub clone {
222 16 ▶ my $self = shift;
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
223 16 bless {%$self, @_}, ref $self;
224 }
225  
226 54 ▶sub inc { $_[0]->{inc} ||= \@INC }
Subroutine inc: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$_[0]{"inc"} ||= \@INC
l!l
3519
MC/DC100%1/1
$_[0]{"inc"} ||= \@INC
$_[0]{"inc"}
Truth table100%2/2
A
A= $_[0]{"inc"}
Aresult
11
00
227 28 ▶sub libs { $_[0]->{libs} ||= [ \'PERL5LIB' ] }
Subroutine libs: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$_[0]{"libs"} ||= [\"PERL5LIB"]
l!l
1414
MC/DC100%1/1
$_[0]{"libs"} ||= [\"PERL5LIB"]
$_[0]{"libs"}
Truth table100%2/2
A
A= $_[0]{"libs"}
Aresult
11
00
228 28 ▶sub bins { $_[0]->{bins} ||= [ \'PATH' ] }
Subroutine bins: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$_[0]{"bins"} ||= [\"PATH"]
l!l
1414
MC/DC100%1/1
$_[0]{"bins"} ||= [\"PATH"]
$_[0]{"bins"}
Truth table100%2/2
A
A= $_[0]{"bins"}
Aresult
11
00
229 50 ▶sub roots { $_[0]->{roots} ||= [ \'PERL_LOCAL_LIB_ROOT' ] }
Subroutine roots: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$_[0]{"roots"} ||= [\"PERL_LOCAL_LIB_ROOT"]
l!l
3020
MC/DC100%1/1
$_[0]{"roots"} ||= [\"PERL_LOCAL_LIB_ROOT"]
$_[0]{"roots"}
Truth table100%2/2
A
A= $_[0]{"roots"}
Aresult
11
00
230 14 ▶sub extra { $_[0]->{extra} ||= {} }
Subroutine extra: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
$_[0]{"extra"} ||= {}
l!l
140
MC/DC0%0/1
$_[0]{"extra"} ||= {}
$_[0]{"extra"}
Truth table50%1/2
A
A= $_[0]{"extra"}
Aresult
11
00
231 12 ▶sub quiet { $_[0]->{quiet} }
Subroutine quiet: called CC=1 SCAR=0.0
Pod undocumented
232  
233 sub _as_list {
234 76 ▶ my $list = shift;
Subroutine _as_list: called CC=5 SCAR=16.3
235 grep length, map {
236 76 !(ref $_ && ref $_ eq 'SCALAR') ? $_ : (
237 185 ▶ defined $ENV{$$_} ? split(/\Q$_path_sep/, $ENV{$$_})
Branch: 3 branches
BranchTrueFalseTotal
!(ref $_ && ref $_ eq 'SCALAR') ? : 121 64 185
defined $ENV{$$_} ? : 51 13 64
ref $list ? : 76 0 76
Condition66%2/3
ref $_ && ref $_ eq 'SCALAR'
!ll&&!rl&&r
121064
MC/DC50%1/2
ref $_ && ref $_ eq 'SCALAR'
ref $_ ref $_ eq 'SCALAR'
Truth table66%2/3
A && B
A= ref $_B= ref $_ eq 'SCALAR'
ABresult
0X0
100
111
238 : ()
239 )
240 } ref $list ? @$list : $list;
241 }
242 sub _remove_from {
243 12 ▶ my ($list, @remove) = @_;
Subroutine _remove_from: called CC=2 SCAR=7.0
244 12 ▶ return @$list
Branch: 1 branch
BranchTrueFalseTotal
unless @remove 0 12 12
245 if !@remove;
246 12 my %remove = map { $_ => 1 } @remove;
247 12 grep !$remove{$_}, _as_list($list);
248 }
249  
250 9 my @_lib_subdirs = (
251 [$_version, $_archname],
252 [$_version],
253 [$_archname],
254 (map [$_], @_inc_version_list),
255 [],
256 );
257  
258 sub install_base_bin_path {
259 41 ▶ my ($class, $path) = @_;
Subroutine install_base_bin_path: called CC=1 SCAR=0.0
Pod documented
260 41 return _catdir($path, 'bin');
261 }
262 sub install_base_perl_path {
263 84 ▶ my ($class, $path) = @_;
Subroutine install_base_perl_path: called CC=1 SCAR=0.0
Pod documented
264 84 return _catdir($path, 'lib', 'perl5');
265 }
266 sub install_base_arch_path {
267 1 ▶ my ($class, $path) = @_;
Subroutine install_base_arch_path: called CC=1 SCAR=0.0
Pod undocumented
268 1 _catdir($class->install_base_perl_path($path), $_archname);
269 }
270  
271 sub lib_paths_for {
272 36 ▶ my ($class, $path) = @_;
Subroutine lib_paths_for: called CC=1 SCAR=0.0
Pod documented
273 36 my $base = $class->install_base_perl_path($path);
274 36 return map { _catdir($base, @$_) } @_lib_subdirs;
275 }
276  
277 sub _mm_escape_path {
278 22 ▶ my $path = shift;
Subroutine _mm_escape_path: called CC=2 SCAR=7.4
279 22 $path =~ s/\\/\\\\/g;
280 22 ▶ if ($path =~ s/ /\\ /g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ s/ /\\ /g) 0 22 22
281 0 $path = qq{"$path"};
282 }
283 22 return $path;
284 }
285  
286 sub _mb_escape_path {
287 20 ▶ my $path = shift;
Subroutine _mb_escape_path: called CC=1 SCAR=0.0
288 20 $path =~ s/\\/\\\\/g;
289 20 return qq{"$path"};
290 }
291  
292 sub installer_options_for {
293 20 ▶ my ($class, $path) = @_;
Subroutine installer_options_for: called CC=3 SCAR=12.0
Pod documented
294 return (
295 20 ▶ PERL_MM_OPT =>
Branch: 2 branches
BranchTrueFalseTotal
defined $path ? : 20 0 20
defined $path ? : 20 0 20
296 defined $path ? "INSTALL_BASE="._mm_escape_path($path) : undef,
297 PERL_MB_OPT =>
298 defined $path ? "--install_base "._mb_escape_path($path) : undef,
299 );
300 }
301  
302 sub active_paths {
303 22 ▶ my ($self) = @_;
Subroutine active_paths: called CC=2 SCAR=6.9
Pod documented
304 22 ▶ $self = ref $self ? $self : $self->new;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 16 6 22
305  
306 return grep {
307 # screen out entries that aren't actually reflected in @INC
308 22 my $active_ll = $self->install_base_perl_path($_);
309 26 grep { $_ eq $active_ll } @{$self->inc};
310 } _as_list($self->roots);
311 }
312  
313  
314 sub deactivate {
315 3 ▶ my ($self, $path) = @_;
Subroutine deactivate: called CC=3 SCAR=11.4
Pod documented
316 3 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 3 3
317 3 $path = $self->resolve_path($path);
318 3 $path = $self->normalize_path($path);
319  
320 3 my @active_lls = $self->active_paths;
321  
322 3 ▶ if (!grep { $_ eq $path } @active_lls) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $path;} @active_lls) 0 3 3
323 0 warn "Tried to deactivate inactive local::lib '$path'\n";
324 0 return $self;
325 }
326  
327 3 my %args = (
328 bins => [ _remove_from($self->bins,
329 $self->install_base_bin_path($path)) ],
330 libs => [ _remove_from($self->libs,
331 $self->install_base_perl_path($path)) ],
332 inc => [ _remove_from($self->inc,
333 $self->lib_paths_for($path)) ],
334 roots => [ _remove_from($self->roots, $path) ],
335 );
336  
337 3 $args{extra} = { $self->installer_options_for($args{roots}[0]) };
338  
339 3 $self->clone(%args);
340 }
341  
342 sub deactivate_all {
343 0 ▶ my ($self) = @_;
Subroutine deactivate_all: not called CC=3 SCAR=24.8
Pod documented
344 0 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
345  
346 0 my @active_lls = $self->active_paths;
347  
348 0 my %args;
349 0 ▶ if (@active_lls) {
Branch: 1 branch
BranchTrueFalseTotal
if (@active_lls) 0 0 0
350 0 %args = (
351 bins => [ _remove_from($self->bins,
352 map $self->install_base_bin_path($_), @active_lls) ],
353 libs => [ _remove_from($self->libs,
354 map $self->install_base_perl_path($_), @active_lls) ],
355 inc => [ _remove_from($self->inc,
356 map $self->lib_paths_for($_), @active_lls) ],
357 roots => [ _remove_from($self->roots, @active_lls) ],
358 );
359 }
360  
361 0 $args{extra} = { $self->installer_options_for(undef) };
362  
363 0 $self->clone(%args);
364 }
365  
366 sub activate {
367 13 ▶ my ($self, $path, $opts) = @_;
Subroutine activate: called CC=8 SCAR=20.8
Pod documented
368 13 ▶ $opts ||= {};
Condition50%1/2
$opts ||= {}
l!l
130
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
369 13 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 13 13
370 13 $path = $self->resolve_path($path);
371 $self->ensure_dir_structure_for($path, { quiet => $self->quiet })
372 13 ▶ unless $opts->{no_create};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts->{"no_create"} 12 1 13
373  
374 13 $path = $self->normalize_path($path);
375  
376 13 my @active_lls = $self->active_paths;
377  
378 13 ▶ if (grep { $_ eq $path } @active_lls[1 .. $#active_lls]) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $path;} @active_lls[1 .. $#active_lls]) 2 11 13
379 2 $self = $self->deactivate($path);
380 }
381  
382 13 my %args;
383 13 ▶ if ($opts->{always} || !@active_lls || $active_lls[0] ne $path) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"always"} or not @active_lls or $active_lls[0] ne $path) 11 2 13
Condition83%5/6
$opts->{"always"} or not @active_lls or $active_lls[0] ne $path
l!l&&r!l&&!r
652
$opts->{"always"} or not @active_lls
l!l&&r!l&&!r
067
MC/DC66%2/3
$opts->{"always"} or not @active_lls or $active_lls[0] ne $path
$opts->{"always"} not @active_lls $active_lls[0] ne $path
Truth table75%3/4
A or not(B) or C
A= $opts->{"always"}B= not @active_llsC= $active_lls[0] ne $path
ABCresult
1XX1
01X1
0011
0000
384 %args = (
385 11 bins => [ $self->install_base_bin_path($path), @{$self->bins} ],
386 11 libs => [ $self->install_base_perl_path($path), @{$self->libs} ],
387 11 inc => [ $self->lib_paths_for($path), @{$self->inc} ],
388 11 roots => [ $path, @{$self->roots} ],
389 );
390 }
391  
392 13 $args{extra} = { $self->installer_options_for($path) };
393  
394 13 $self->clone(%args);
395 }
396  
397 sub normalize_path {
398 29 ▶ my ($self, $path) = @_;
Subroutine normalize_path: called CC=3 SCAR=14.2
Pod undocumented
399 29 ▶ $path = ( Win32::GetShortPathName($path) || $path )
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 29 29
Condition0%0/3
Win32::GetShortPathName($path) || $path
l!l&&r!l&&!r
000
MC/DC0%0/2
Win32::GetShortPathName($path) || $path
Win32::GetShortPathName($path) $path
Truth table0%0/3
A || B
A= Win32::GetShortPathName($path)B= $path
ABresult
1X1
011
000
400 if $^O eq 'MSWin32';
401 29 return $path;
402 }
403  
404 sub build_environment_vars_for {
405 0 ▶ my $self = $_[0]->new->activate($_[1], { always => 1 });
Subroutine build_environment_vars_for: not called CC=1 SCAR=6.9
Pod documented
406 0 $self->build_environment_vars;
407 }
408 sub build_activate_environment_vars_for {
409 0 ▶ my $self = $_[0]->new->activate($_[1], { always => 1 });
Subroutine build_activate_environment_vars_for: not called CC=1 SCAR=6.9
Pod undocumented
410 0 $self->build_environment_vars;
411 }
412 sub build_deactivate_environment_vars_for {
413 0 ▶ my $self = $_[0]->new->deactivate($_[1]);
Subroutine build_deactivate_environment_vars_for: not called CC=1 SCAR=6.9
Pod undocumented
414 0 $self->build_environment_vars;
415 }
416 sub build_deact_all_environment_vars_for {
417 0 ▶ my $self = $_[0]->new->deactivate_all;
Subroutine build_deact_all_environment_vars_for: not called CC=1 SCAR=6.9
Pod undocumented
418 0 $self->build_environment_vars;
419 }
420 sub build_environment_vars {
421 14 ▶ my $self = shift;
Subroutine build_environment_vars: called CC=1 SCAR=0.0
Pod documented
422 (
423 PATH => join($_path_sep, _as_list($self->bins)),
424 PERL5LIB => join($_path_sep, _as_list($self->libs)),
425 PERL_LOCAL_LIB_ROOT => join($_path_sep, _as_list($self->roots)),
426 14 %{$self->extra},
427 );
428 }
429  
430 sub setup_local_lib_for {
431 0 ▶ my $self = $_[0]->new->activate($_[1]);
Subroutine setup_local_lib_for: not called CC=1 SCAR=6.9
Pod undocumented
432 0 $self->setup_local_lib;
433 }
434  
435 sub setup_local_lib {
436 14 ▶ my $self = shift;
Subroutine setup_local_lib: called CC=2 SCAR=7.0
Pod documented
437  
438 # if Carp is already loaded, ensure Carp::Heavy is also loaded, to avoid
439 # $VERSION mismatch errors (Carp::Heavy loads Carp, so we do not need to
440 # check in the other direction)
441 14 ▶ require Carp::Heavy if $INC{'Carp.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"Carp.pm"} 14 0 14
442  
443 14 $self->setup_env_hash;
444 14 @INC = @{$self->inc};
445 }
446  
447 sub setup_env_hash_for {
448 0 ▶ my $self = $_[0]->new->activate($_[1]);
Subroutine setup_env_hash_for: not called CC=1 SCAR=6.9
Pod documented
449 0 $self->setup_env_hash;
450 }
451 sub setup_env_hash {
452 14 ▶ my $self = shift;
Subroutine setup_env_hash: called CC=3 SCAR=11.4
Pod documented
453 14 my %env = $self->build_environment_vars;
454 14 for my $key (keys %env) {
455 70 ▶ if (defined $env{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $env{$key}) { } 70 0 70
456 70 $ENV{$key} = $env{$key};
457 }
458 else {
459 0 delete $ENV{$key};
460 }
461 }
462 }
463  
464 sub print_environment_vars_for {
465 0 ▶ print $_[0]->environment_vars_string_for(@_[1..$#_]);
Subroutine print_environment_vars_for: not called CC=1 SCAR=6.9
Pod documented
466 }
467  
468 sub environment_vars_string_for {
469 0 ▶ my $self = $_[0]->new->activate($_[1], { always => 1});
Subroutine environment_vars_string_for: not called CC=1 SCAR=6.9
Pod undocumented
470 0 $self->environment_vars_string;
471 }
472 sub environment_vars_string {
473 0 ▶ my ($self, $shelltype) = @_;
Subroutine environment_vars_string: not called CC=2 SCAR=17.9
Pod documented
474  
475 0 ▶ $shelltype ||= $self->guess_shelltype;
Condition0%0/3
$shelltype ||= $self->guess_shelltype
l!l&&r!l&&!r
000
MC/DC0%0/2
$shelltype ||= $self->guess_shelltype
$shelltype $self->guess_shelltype
Truth table0%0/3
A ||= B
A= $shelltypeB= $self->guess_shelltype
ABresult
1X1
011
000
476  
477 0 my $extra = $self->extra;
478 my @envs = (
479 PATH => $self->bins,
480 PERL5LIB => $self->libs,
481 PERL_LOCAL_LIB_ROOT => $self->roots,
482 0 map { $_ => $extra->{$_} } sort keys %$extra,
483 );
484 0 $self->_build_env_string($shelltype, \@envs);
485 }
486  
487 sub _build_env_string {
488 56 ▶ my ($self, $shelltype, $envs) = @_;
Subroutine _build_env_string: called CC=8 SCAR=24.3
489 56 my @envs = @$envs;
490  
491 56 my $build_method = "build_${shelltype}_env_declaration";
492  
493 56 my $out = '';
494 56 ▶ while (@envs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@envs) 56 56 112
495 56 my ($name, $value) = (shift(@envs), shift(@envs));
496 56 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value and @$value == 1 and ref $value->[0] and ref $value->[0] eq "SCALAR" and ${$value->[0];} eq $name) 0 56 56
Condition41%5/12
ref $value and @$value == 1 and ref $value->[0] and ref $value->[0] eq "SCALAR" and ${$value->[0];} eq $name
!ll&&!rl&&r
5600
ref $value and @$value == 1 and ref $value->[0] and ref $value->[0] eq "SCALAR"
!ll&&!rl&&r
5600
ref $value and @$value == 1 and ref $value->[0]
!ll&&!rl&&r
5600
ref $value and @$value == 1
!ll&&!rl&&r
28280
MC/DC0%0/5
ref $value and @$value == 1 and ref $value->[0] and ref $value->[0] eq "SCALAR" and ${$value->[0];} eq $name
ref $value @$value == 1 ref $value->[0] ref $value->[0] eq "SCALAR" ${$value->[0];} eq $name
Truth table33%2/6
A and B and C and D and E
A= ref $valueB= @$value == 1C= ref $value->[0]D= ref $value->[0] eq "SCALAR"E= ${$value->[0];} eq $name
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
497 ref $value
498 && @$value == 1
499 && ref $value->[0]
500 && ref $value->[0] eq 'SCALAR'
501 0 && ${$value->[0]} eq $name) {
502 0 next;
503 }
504 56 $out .= $self->$build_method($name, $value);
505 }
506 56 my $wrap_method = "wrap_${shelltype}_output";
507 56 ▶ if ($self->can($wrap_method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($wrap_method)) 0 56 56
508 0 return $self->$wrap_method($out);
509 }
510 56 return $out;
511 }
512  
513 sub build_bourne_env_declaration {
514 56 ▶ my ($class, $name, $args) = @_;
Subroutine build_bourne_env_declaration: called CC=2 SCAR=7.1
Pod undocumented
515 56 my $value = $class->_interpolate($args, '${%s:-}', qr/["\\\$!`]/, '\\%s');
516  
517 56 ▶ if (!defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 0 56 56
518 0 return qq{unset $name;\n};
519 }
520  
521 56 $value =~ s/(^|\G|$_path_sep)\$\{$name:-\}$_path_sep/$1\${$name}\${$name:+$_path_sep}/g;
522 56 $value =~ s/$_path_sep\$\{$name:-\}$/\${$name:+$_path_sep\${$name}}/;
523  
524 56 qq{${name}="$value"; export ${name};\n}
525 }
526  
527 sub build_csh_env_declaration {
528 0 ▶ my ($class, $name, $args) = @_;
Subroutine build_csh_env_declaration: not called CC=4 SCAR=30.0
Pod undocumented
529 0 my ($value, @vars) = $class->_interpolate($args, '${%s}', qr/["\$]/, '"\\%s"');
530 0 ▶ if (!defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 0 0 0
531 0 return qq{unsetenv $name;\n};
532 }
533  
534 0 my $out = '';
535 0 for my $var (@vars) {
536 0 $out .= qq{if ! \$?$name setenv $name '';\n};
537 }
538  
539 0 my $value_without = $value;
540 0 ▶ if ($value_without =~ s/(?:^|$_path_sep)\$\{$name\}(?:$_path_sep|$)//g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value_without =~ s/(?:^|$_path_sep)\$\{$name\}(?:$_path_sep|$)//g) 0 0 0
541 0 $out .= qq{if "\${$name}" != '' setenv $name "$value";\n};
542 0 $out .= qq{if "\${$name}" == '' };
543 }
544 0 $out .= qq{setenv $name "$value_without";\n};
545 0 return $out;
546 }
547  
548 sub build_cmd_env_declaration {
549 0 ▶ my ($class, $name, $args) = @_;
Subroutine build_cmd_env_declaration: not called CC=3 SCAR=24.8
Pod undocumented
550 0 my $value = $class->_interpolate($args, '%%%s%%', qr(%), '%s');
551 0 ▶ if (!$value) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value) 0 0 0
552 0 return qq{\@set $name=\n};
553 }
554  
555 0 my $out = '';
556 0 my $value_without = $value;
557 0 ▶ if ($value_without =~ s/(?:^|$_path_sep)%$name%(?:$_path_sep|$)//g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value_without =~ s/(?:^|$_path_sep)%$name%(?:$_path_sep|$)//g) 0 0 0
558 0 $out .= qq{\@if not "%$name%"=="" set "$name=$value"\n};
559 0 $out .= qq{\@if "%$name%"=="" };
560 }
561 0 $out .= qq{\@set "$name=$value_without"\n};
562 0 return $out;
563 }
564  
565 sub build_powershell_env_declaration {
566 0 ▶ my ($class, $name, $args) = @_;
Subroutine build_powershell_env_declaration: not called CC=2 SCAR=17.9
Pod undocumented
567 0 my $value = $class->_interpolate($args, '$env:%s', qr/["\$]/, '`%s');
568  
569 0 ▶ if (!$value) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value) 0 0 0
570 0 return qq{Remove-Item -ErrorAction 0 Env:\\$name;\n};
571 }
572  
573 0 my $maybe_path_sep = qq{\$(if("\$env:$name"-eq""){""}else{"$_path_sep"})};
574 0 $value =~ s/(^|\G|$_path_sep)\$env:$name$_path_sep/$1\$env:$name"+$maybe_path_sep+"/g;
575 0 $value =~ s/$_path_sep\$env:$name$/"+$maybe_path_sep+\$env:$name+"/;
576  
577 0 qq{\$env:$name = \$("$value");\n};
578 }
579 sub wrap_powershell_output {
580 0 ▶ my ($class, $out) = @_;
Subroutine wrap_powershell_output: not called CC=2 SCAR=17.9
Pod undocumented
581 0 ▶ return $out || " \n";
Condition0%0/2
$out || " \n"
l!l
00
MC/DC0%0/1
$out || " \n"
$out
Truth table0%0/2
A
A= $out
Aresult
11
00
582 }
583  
584 sub build_fish_env_declaration {
585 0 ▶ my ($class, $name, $args) = @_;
Subroutine build_fish_env_declaration: not called CC=5 SCAR=34.0
Pod undocumented
586 0 my $value = $class->_interpolate($args, '$%s', qr/[\\"'$ ]/, '\\%s');
587 0 ▶ if (!defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 0 0 0
588 0 return qq{set -e $name;\n};
589 }
590  
591 # fish has special handling for PATH, CDPATH, and MANPATH. They are always
592 # treated as arrays, and joined with ; when storing the environment. Other
593 # env vars can be arrays, but will be joined without a separator. We only
594 # really care about PATH, but might as well make this routine more general.
595 0 ▶ if ($name =~ /^(?:CD|MAN)?PATH$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(?:CD|MAN)?PATH$/) 0 0 0
596 0 $value =~ s/$_path_sep/ /g;
597 0 ▶ my $silent = $name =~ /^(?:CD)?PATH$/ ? " 2>"._devnull : '';
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^(?:CD)?PATH$/ ? : 0 0 0
598 0 return qq{set -x $name $value$silent;\n};
599 }
600  
601 0 my $out = '';
602 0 my $value_without = $value;
603 0 ▶ if ($value_without =~ s/(?:^|$_path_sep)\$$name(?:$_path_sep|$)//g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value_without =~ s/(?:^|$_path_sep)\$$name(?:$_path_sep|$)//g) 0 0 0
604 0 $out .= qq{set -q $name; and set -x $name $value;\n};
605 0 $out .= qq{set -q $name; or };
606 }
607 0 $out .= qq{set -x $name $value_without;\n};
608 0 $out;
609 }
610  
611 sub _interpolate {
612 56 ▶ my ($class, $args, $var_pat, $escape, $escape_pat) = @_;
Subroutine _interpolate: called CC=6 SCAR=18.0
613 return
614 56 ▶ unless defined $args;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args 0 56 56
615 56 ▶ my @args = ref $args ? @$args : $args;
Branch: 1 branch
BranchTrueFalseTotal
ref $args ? : 28 28 56
616 return
617 56 ▶ unless @args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 56 56
618 56 my @vars = map { $$_ } grep { ref $_ eq 'SCALAR' } @args;
619 my $string = join $_path_sep, map {
620 56 ▶ ref $_ eq 'SCALAR' ? sprintf($var_pat, $$_) : do {
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'SCALAR' ? : 28 56 84
621 56 s/($escape)/sprintf($escape_pat, $1)/ge; $_;
622 };
623 } @args;
624 56 ▶ return wantarray ? ($string, \@vars) : $string;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 56 56
625 }
626  
627 sub pipeline;
628  
629 sub pipeline {
630 51 ▶ my @methods = @_;
Subroutine pipeline: called CC=2 SCAR=6.9
Pod undocumented
631 51 my $last = pop(@methods);
632 51 ▶ if (@methods) {
Branch: 1 branch
BranchTrueFalseTotal
if (@methods) { } 34 17 51
633 \sub {
634 34 ▶ my ($obj, @args) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
635 34 $obj->${pipeline @methods}(
636 $obj->$last(@args)
637 );
638 34 };
639 } else {
640 \sub {
641 17 ▶ shift->$last(@_);
Subroutine __ANON__: called CC=1 SCAR=0.0
642 17 };
643 }
644 }
645  
646 sub resolve_path {
647 16 ▶ my ($class, $path) = @_;
Subroutine resolve_path: called CC=1 SCAR=0.0
Pod documented
648  
649 16 $path = $class->${pipeline qw(
650 resolve_relative_path
651 resolve_home_path
652 resolve_empty_path
653 )}($path);
654  
655 16 $path;
656 }
657  
658 sub resolve_empty_path {
659 18 ▶ my ($class, $path) = @_;
Subroutine resolve_empty_path: called CC=2 SCAR=6.9
Pod documented
660 18 ▶ if (defined $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $path) { } 17 1 18
661 17 $path;
662 } else {
663 1 '~/perl5';
664 }
665 }
666  
667 sub resolve_home_path {
668 16 ▶ my ($class, $path) = @_;
Subroutine resolve_home_path: called CC=6 SCAR=34.2
Pod documented
669 16 ▶ $path =~ /^~([^\/]*)/ or return $path;
Branch: 1 branch
BranchTrueFalseTotal
$path =~ m[^~([^/]*)] or return $path 16 0 16
670 0 my $user = $1;
671 0 my $homedir = do {
672 0 ▶ if (! length($user) && defined $ENV{HOME}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not length $user and defined $ENV{'HOME'}) { } 0 0 0
Condition0%0/3
not length $user and defined $ENV{"HOME"}
!ll&&!rl&&r
000
MC/DC0%0/2
not length $user and defined $ENV{"HOME"}
not length $user defined $ENV{"HOME"}
Truth table0%0/3
not(A) and B
A= not length $userB= defined $ENV{"HOME"}
ABresult
0X0
100
111
673 0 $ENV{HOME};
674 }
675 else {
676 0 require File::Glob;
677 0 File::Glob::bsd_glob("~$user", File::Glob::GLOB_TILDE());
678 }
679 };
680 0 ▶ unless (defined $homedir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $homedir) 0 0 0
681 0 require Carp; require Carp::Heavy;
682 0 ▶ Carp::croak(
Branch: 1 branch
BranchTrueFalseTotal
defined $user ? : 0 0 0
683 "Couldn't resolve homedir for "
684 .(defined $user ? $user : 'current user')
685 );
686 }
687 0 $path =~ s/^~[^\/]*/$homedir/;
688 0 $path;
689 }
690  
691 sub resolve_relative_path {
692 16 ▶ my ($class, $path) = @_;
Subroutine resolve_relative_path: called CC=1 SCAR=0.0
Pod documented
693 16 _rel2abs($path);
694 }
695  
696 sub ensure_dir_structure_for {
697 22 ▶ my ($class, $path, $opts) = @_;
Subroutine ensure_dir_structure_for: called CC=10 SCAR=23.1
Pod documented
698 22 ▶ $opts ||= {};
Condition100%2/2
$opts ||= {}
l!l
211
MC/DC100%1/1
$opts ||= {}
$opts
Truth table100%2/2
A
A= $opts
Aresult
11
00
699 22 my @dirs;
700 22 foreach my $dir (
701 $class->lib_paths_for($path),
702 $class->install_base_bin_path($path),
703 ) {
704 110 my $d = $dir;
705 110 ▶ while (!-d $d) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $d) 135 110 245
706 135 push @dirs, $d;
707 135 require File::Basename;
708 135 $d = File::Basename::dirname($d);
709 }
710 }
711  
712 warn "Attempting to create directory ${path}\n"
713 22 ▶ if !$opts->{quiet} && @dirs;
Branch: 1 branch
BranchTrueFalseTotal
if not $opts->{"quiet"} and @dirs 1 21 22
Condition100%3/3
not $opts->{"quiet"} and @dirs
!ll&&!rl&&r
9121
MC/DC100%2/2
not $opts->{"quiet"} and @dirs
not $opts->{"quiet"} @dirs
Truth table100%3/3
not(A) and B
A= not $opts->{"quiet"}B= @dirs
ABresult
0X0
100
111
714  
715 22 my %seen;
716 22 foreach my $dir (reverse @dirs) {
717 next
718 135 ▶ if $seen{$dir}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$dir}++ 74 61 135
719  
720 61 ▶ mkdir $dir
Branch: 1 branch
BranchTrueFalseTotal
mkdir $dir or -d $dir or die "Unable to create ${dir}: $!" 0 61 61
Condition33%1/3
mkdir $dir or -d $dir
l!l&&r!l&&!r
6100
MC/DC0%0/2
mkdir $dir or -d $dir
mkdir $dir -d $dir
Truth table33%1/3
A or B
A= mkdir $dirB= -d $dir
ABresult
1X1
011
000
721 or -d $dir
722 or die "Unable to create $dir: $!"
723 }
724 22 return;
725 }
726  
727 sub guess_shelltype {
728 my $shellbin
729 = defined $ENV{SHELL} && length $ENV{SHELL}
730 ? ($ENV{SHELL} =~ /([\w.]+)$/)[-1]
731 : ( $^O eq 'MSWin32' && exists $ENV{'!EXITCODE'} )
732 ? 'bash'
733 : ( $^O eq 'MSWin32' && $ENV{PROMPT} && $ENV{COMSPEC} )
734 ? ($ENV{COMSPEC} =~ /([\w.]+)$/)[-1]
735 : ( $^O eq 'MSWin32' && !$ENV{PROMPT} )
736 4 ▶ ? 'powershell.exe'
Subroutine guess_shelltype: called CC=17 SCAR=47.9
Pod undocumented
Branch: 4 branches
BranchTrueFalseTotal
defined $ENV{'SHELL'} && length $ENV{'SHELL'} ? : 4 0 4
$^O eq 'MSWin32' && exists $ENV{'!EXITCODE'} ? : 0 0 0
$^O eq 'MSWin32' && $ENV{'PROMPT'} && $ENV{'COMSPEC'} ? : 0 0 0
$^O eq 'MSWin32' && !$ENV{'PROMPT'} ? : 0 0 0
Condition6%1/15
defined $ENV{"SHELL"} and length $ENV{"SHELL"}
!ll&&!rl&&r
004
$^O eq "MSWin32" and exists $ENV{"!EXITCODE"}
!ll&&!rl&&r
000
$^O eq "MSWin32" and $ENV{"PROMPT"} and $ENV{"COMSPEC"}
!ll&&!rl&&r
000
$^O eq "MSWin32" and $ENV{"PROMPT"}
!ll&&!rl&&r
000
$^O eq "MSWin32" and not $ENV{"PROMPT"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ENV{"SHELL"} and length $ENV{"SHELL"}
defined $ENV{"SHELL"} length $ENV{"SHELL"}
MC/DC0%0/2
$^O eq "MSWin32" and exists $ENV{"!EXITCODE"}
$^O eq "MSWin32" exists $ENV{"!EXITCODE"}
MC/DC0%0/3
$^O eq "MSWin32" and $ENV{"PROMPT"} and $ENV{"COMSPEC"}
$^O eq "MSWin32" $ENV{"PROMPT"} $ENV{"COMSPEC"}
MC/DC0%0/2
$^O eq "MSWin32" and not $ENV{"PROMPT"}
$^O eq "MSWin32" not $ENV{"PROMPT"}
Truth table33%1/3
A and B
A= defined $ENV{"SHELL"}B= length $ENV{"SHELL"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $^O eq "MSWin32"B= exists $ENV{"!EXITCODE"}
ABresult
0X0
100
111
Truth table0%0/4
A and B and C
A= $^O eq "MSWin32"B= $ENV{"PROMPT"}C= $ENV{"COMSPEC"}
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A and not(B)
A= $^O eq "MSWin32"B= not $ENV{"PROMPT"}
ABresult
0X0
100
111
737 : 'sh';
738  
739 4 for ($shellbin) {
740 return
741 4 ▶ /csh$/ ? 'csh'
Branch: 6 branches
BranchTrueFalseTotal
/csh$/ ? : 0 4 4
/fish$/ ? : 0 4 4
/command(?:\.com)?$/i ? : 0 4 4
/cmd(?:\.exe)?$/i ? : 0 4 4
/4nt(?:\.exe)?$/i ? : 0 4 4
/powershell(?:\.exe)?$/i ? : 0 4 4
742 : /fish$/ ? 'fish'
743 : /command(?:\.com)?$/i ? 'cmd'
744 : /cmd(?:\.exe)?$/i ? 'cmd'
745 : /4nt(?:\.exe)?$/i ? 'cmd'
746 : /powershell(?:\.exe)?$/i ? 'powershell'
747 : 'bourne';
748 }
749 }
750  
751 9 1;
752 __END__
↑ Summary lib/core/only.pm »