local/lib.pm

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