lib/Rex/Interface/Shell.pm

filter: Statementstmt 75.0% 21 / 28 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 3 totaltotal 70.0% 28 / 40 CC 2 SCAR 3.5
CC
2
Cov
73%
create
2.1
register_shell_provider
2.0
BEGIN
1.0
CRAP 1.4
« lib/Rex/Hardware.pm ↑ Summary lib/Rex/Value.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Interface::Shell;
6  
7 60 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 60 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 60 our $VERSION = '1.16.1'; # VERSION
11  
12 60 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 60 my %SHELL_PROVIDER = (
15 ash => "Rex::Interface::Shell::Ash",
16 bash => "Rex::Interface::Shell::Bash",
17 csh => "Rex::Interface::Shell::Csh",
18 idrac => "Rex::Interface::Shell::Idrac",
19 ksh => "Rex::Interface::Shell::Ksh",
20 sh => "Rex::Interface::Shell::Sh",
21 tcsh => "Rex::Interface::Shell::Tcsh",
22 zsh => "Rex::Interface::Shell::Zsh",
23 );
24  
25 0 ▶sub register_shell_provider {
Subroutine register_shell_provider: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my ( $class, $shell_name, $shell_class ) = @_;
27 0 $SHELL_PROVIDER{"\L$shell_name"} = $shell_class;
28 0 return 1;
29 }
30  
31 2 ▶sub get_shell_provider {
Subroutine get_shell_provider: called CC=1 SCAR=0.0
Pod undocumented
32 2 return %SHELL_PROVIDER;
33 }
34  
35 2 ▶sub create {
Subroutine create: called CC=2 SCAR=7.6
Pod undocumented
36 2 my ( $class, $shell ) = @_;
37  
38 2 $shell =~ s/[\r\n]//gms; # sometimes there are some wired things...
39  
40 2 my $klass = "Rex::Interface::Shell::\u$shell";
41 2 ▶ eval "use $klass";
Subroutine BEGIN: called CC=1 SCAR=0.0
42 2 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 2 2
43 0 Rex::Logger::info(
44 "Can't load wanted shell: '$shell' ('$klass'). Using default shell.",
45 "warn" );
46 0 Rex::Logger::info(
47 "If you want to help the development of Rex please report this issue in our Github issue tracker.",
48 "warn"
49 );
50 0 $klass = "Rex::Interface::Shell::Default";
51 0 eval "use $klass";
52 }
53  
54 2 return $klass->new;
55 }
56  
57 60 1;
« lib/Rex/Hardware.pm ↑ Summary lib/Rex/Value.pm »