OpenSSH/ShellQuoter/POSIX.pm

filter: Statementstmt 50.0% 18 / 36 Branchbran 26.9% 7 / 26 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 4 totaltotal 39.4% 30 / 76 CC 15 SCAR 40.0
CC
15
Cov
39%
quote_glob
110.0
shell_fragments
6.0
quote
5.0
CRAP 54.3
« OpenSSH/OSTracer.pm ↑ Summary OpenSSH/ShellQuoter/fish.pm »
1 package Net::OpenSSH::ShellQuoter::POSIX;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶sub new { __PACKAGE__ }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8  
9 1 my $noquote_class = '.\\w/\\-@,:';
10 1 my $glob_class = '*?\\[\\],\\{\\}:!^~';
11  
12 1827 ▶sub quote {
Subroutine quote: called CC=5 SCAR=16.1
Pod undocumented
13 1827 shift;
14 my $quoted = join '',
15 1827 ▶ map { ( m|\A'\z| ? "\\'" :
Branch: 3 branches
BranchTrueFalseTotal
/\A'\z/ ? : 1449 3303 4752
/\A'/ ? : 18 3285 3303
/\A[$noquote_class]+\z/o ? : 612 2673 3285
16 m|\A'| ? "\"$_\"" :
17 m|\A[$noquote_class]+\z|o ? $_ :
18 "'$_'" )
19 } split /('+)/, $_[0];
20 1827 ▶ length $quoted ? $quoted : "''";
Branch: 1 branch
BranchTrueFalseTotal
length $quoted ? : 1827 0 1827
21 }
22  
23  
24 0 ▶sub quote_glob {
Subroutine quote_glob: not called CC=10 SCAR=47.0
Pod undocumented
25 0 shift;
26 0 my $arg = shift;
27 0 my @parts;
28 0 ▶ while ((pos $arg ||0) < length $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ((pos $arg || 0) < length $arg) 0 0 0
Condition0%0/2
pos $arg || 0
l!l
00
MC/DC0%0/1
pos $arg || 0
pos $arg
Truth table0%0/2
A
A= pos $arg
Aresult
11
00
29 0 ▶ if ($arg =~ m|\G('+)|gc) {
Branch: 5 branches
BranchTrueFalseTotal
if ($arg =~ /\G('+)/cg) { } 0 0 0
elsif ($arg =~ /\G([$noquote_class$glob_class]+)/cog) { } 0 0 0
elsif ($arg =~ /\G(\\[$glob_class\\])/cog) { } 0 0 0
elsif ($arg =~ /\G\\/cg) { } 0 0 0
elsif ($arg =~ /\G([^$glob_class\\']+)/cog) { } 0 0 0
30 0 ▶ push @parts, (length($1) > 1 ? "\"$1\"" : "\\'");
Branch: 1 branch
BranchTrueFalseTotal
length $1 > 1 ? : 0 0 0
31 }
32 elsif ($arg =~ m|\G([$noquote_class$glob_class]+)|gco) {
33 0 push @parts, $1;
34 }
35 elsif ($arg =~ m|\G(\\[$glob_class\\])|gco) {
36 0 push @parts, $1;
37 }
38 elsif ($arg =~ m|\G\\|gc) {
39 0 push @parts, '\\\\'
40 }
41 elsif ($arg =~ m|\G([^$glob_class\\']+)|gco) {
42 0 push @parts, "'$1'";
43 }
44 else {
45 0 require Data::Dumper;
46 0 $arg =~ m|\G(.+)|gc;
47 0 die "Internal error: unquotable string:\n". Data::Dumper::Dumper($1) ."\n";
48 }
49 }
50 0 my $quoted = join('', @parts);
51 0 ▶ length $quoted ? $quoted : "''";
Branch: 1 branch
BranchTrueFalseTotal
length $quoted ? : 0 0 0
52 }
53  
54 1 my %fragments = ( stdin_discard => '</dev/null',
55 stdout_discard => '>/dev/null',
56 stderr_discard => '2>/dev/null',
57 stdout_and_stderr_discard => '>/dev/null 2>&1',
58 stderr_to_stdout => '2>&1' );
59  
60 0 ▶sub shell_fragments {
Subroutine shell_fragments: not called CC=2 SCAR=17.9
Pod undocumented
61 0 shift;
62 0 my @f = grep defined, @fragments{@_};
63 0 ▶ wantarray ? @f : join(' ', @f);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
64 }
65  
66 1 1;
« OpenSSH/OSTracer.pm ↑ Summary OpenSSH/ShellQuoter/fish.pm »