blib/lib/Langertha/Holmgang/Shell.pm

filter: Statementstmt 53.8% 760 / 1411 Branchbran 43.4% 495 / 1140 Conditioncond 40.8% 254 / 622 MC/DCmcdc 25.8% 90 / 348 Subroutinesub 69.4% 41 / 59 Podpod 100% 13 / 13 totaltotal 46.0% 1653 / 3593 CC 1072 SCAR 62.0
CC
1072
Cov
48%
_parse_list
1560.5
_parse_list
1560.5
split_items
1207.5
CRAP 491.8
« blib/lib/Langertha/Holmgang/Sim/Linux/Kubernetes.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Docker.pm »
1 package Langertha::Holmgang::Shell;
2 # ABSTRACT: The bash grammar of the simulators — words, items, heredocs, blocks, expansion, test
3  
4 84 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 84 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 84 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 84 our $VERSION = '0.001';
9  
10  
11 # --- Glieder -------------------------------------------------------------------
12  
13  
14 2286 ▶sub split_items {
Subroutine split_items: called CC=71 SCAR=71.0
Pod documented
15 0 ▶ my ($s) = @_;
Subroutine split_items: not called CC=71 SCAR=71.0
Pod documented
16 0 my @items;
17 0 my ( $cur, $op, @docs ) = ( '', ';' );
18 0 my $i = 0;
19 0 my $n = length $s;
20 2778 ▶ my $finish = sub {
Subroutine __ANON__: called CC=6 SCAR=24.2
21 0 ▶ my ($sep) = @_;
Subroutine __ANON__: not called CC=6 SCAR=24.2
22 0 ( my $raw = $cur ) =~ s/\A\s+|\s+\z//g;
23 0 ▶ push @items, { raw => $raw, op => $op, sep => $sep } if length $raw || $sep eq ';;';
Branch: 2 branches
BranchTrueFalseTotal
if length $raw or $sep eq ";;" 2753 25 2778
if length $raw or $sep eq ";;" 0 0 0
Condition33%2/6
length $raw or $sep eq ";;"
l!l&&r!l&&!r
2753025
length $raw or $sep eq ";;"
l!l&&r!l&&!r
000
MC/DC50%1/2
length $raw or $sep eq ";;"
length $raw $sep eq ";;"
MC/DC0%0/2
length $raw or $sep eq ";;"
length $raw $sep eq ";;"
Truth table66%2/3
A or B
A= length $rawB= $sep eq ";;"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= length $rawB= $sep eq ";;"
ABresult
1X1
011
000
24 0 $cur = '';
25 0 ▶ $op = $sep eq '&' || $sep eq "\n" || $sep eq ';;' ? ';' : $sep;
Branch: 2 branches
BranchTrueFalseTotal
$sep eq '&' || $sep eq "\n" || $sep eq ';;' ? : 77 2701 2778
$sep eq '&' || $sep eq "\n" || $sep eq ';;' ? : 0 0 0
Condition50%6/12
$sep eq "&" or $sep eq "\n" or $sep eq ";;"
l!l&&r!l&&!r
7252701
$sep eq "&" or $sep eq "\n"
l!l&&r!l&&!r
1712706
$sep eq "&" or $sep eq "\n" or $sep eq ";;"
l!l&&r!l&&!r
000
$sep eq "&" or $sep eq "\n"
l!l&&r!l&&!r
000
MC/DC100%3/3
$sep eq "&" or $sep eq "\n" or $sep eq ";;"
$sep eq "&" $sep eq "\n" $sep eq ";;"
MC/DC0%0/3
$sep eq "&" or $sep eq "\n" or $sep eq ";;"
$sep eq "&" $sep eq "\n" $sep eq ";;"
Truth table100%4/4
A or B or C
A= $sep eq "&"B= $sep eq "\n"C= $sep eq ";;"
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
A or B or C
A= $sep eq "&"B= $sep eq "\n"C= $sep eq ";;"
ABCresult
1XX1
01X1
0011
0000
26 0 };
27 0 ▶ while ( $i < $n ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i < $n) 71965 2284 74249
if ($i < $n) 0 0 0
28 0 my $c = substr( $s, $i, 1 );
29 0 ▶ if ( $c eq "'" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "'") 346 71619 71965
if ($c eq "'") 0 0 0
30 0 my $j = index( $s, "'", $i + 1 );
31 0 ▶ die "bash: unexpected EOF while looking for matching `''\n" if $j < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j < 0 1 345 346
if $j < 0 0 0 0
32 0 $cur .= substr( $s, $i, $j - $i + 1 );
33 0 $i = $j + 1;
34 0 next;
35 }
36 0 ▶ if ( $c eq '"' || $c eq '`' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\"" or $c eq "`") 257 71362 71619
if ($c eq "\"" or $c eq "`") 0 0 0
Condition50%3/6
$c eq "\"" or $c eq "`"
l!l&&r!l&&!r
256171362
$c eq "\"" or $c eq "`"
l!l&&r!l&&!r
000
MC/DC100%2/2
$c eq "\"" or $c eq "`"
$c eq "\"" $c eq "`"
MC/DC0%0/2
$c eq "\"" or $c eq "`"
$c eq "\"" $c eq "`"
Truth table100%3/3
A or B
A= $c eq "\""B= $c eq "`"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $c eq "\""B= $c eq "`"
ABresult
1X1
011
000
37 0 my $j = _close_quote( $s, $i );
38 0 ▶ die "bash: unexpected EOF while looking for matching `$c'\n" if $j < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j < 0 1 256 257
if $j < 0 0 0 0
39 0 $cur .= substr( $s, $i, $j - $i + 1 );
40 0 $i = $j + 1;
41 0 next;
42 }
43 0 ▶ if ( $c eq '\\' ) { $cur .= substr( $s, $i, 2 ) if substr( $s, $i + 1, 1 ) ne "\n"; $i += 2; next } # \ am Zeilenende: Fortsetzung
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq "\\") 19 71343 71362
if substr($s, $i + 1, 1) ne "\n" 17 2 19
if ($c eq "\\") 0 0 0
if substr($s, $i + 1, 1) ne "\n" 0 0 0
44 0 ▶ if ( $c eq '$' && substr( $s, $i + 1, 1 ) =~ /[({]/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/) 15 71328 71343
if ($c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/) 0 0 0
Condition50%3/6
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
!ll&&!rl&&r
712963215
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
!ll&&!rl&&r
000
MC/DC100%2/2
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
$c eq "\$" substr($s, $i + 1, 1) =~ /[({]/
MC/DC0%0/2
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
$c eq "\$" substr($s, $i + 1, 1) =~ /[({]/
Truth table100%3/3
A and B
A= $c eq "\$"B= substr($s, $i + 1, 1) =~ /[({]/
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $c eq "\$"B= substr($s, $i + 1, 1) =~ /[({]/
ABresult
0X0
100
111
45 0 my $j = _close_paren( $s, $i + 1 );
46 0 ▶ die "bash: unexpected EOF while looking for matching `" . ( substr( $s, $i + 1, 1 ) eq '(' ? ')' : '}' ) . "'\n" if $j < 0;
Branch: 4 branches
BranchTrueFalseTotal
if $j < 0 0 15 15
substr($s, $i + 1, 1) eq '(' ? : 0 0 0
if $j < 0 0 0 0
substr($s, $i + 1, 1) eq '(' ? : 0 0 0
47 0 $cur .= substr( $s, $i, $j - $i + 1 );
48 0 $i = $j + 1;
49 0 next;
50 }
51 0 ▶ if ( $c eq '$' && substr( $s, $i + 1, 1 ) eq "'" ) { # $'…'
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\$" and substr($s, $i + 1, 1) eq "'") 0 71328 71328
if ($c eq "\$" and substr($s, $i + 1, 1) eq "'") 0 0 0
Condition33%2/6
$c eq "\$" and substr($s, $i + 1, 1) eq "'"
!ll&&!rl&&r
71296320
$c eq "\$" and substr($s, $i + 1, 1) eq "'"
!ll&&!rl&&r
000
MC/DC0%0/2
$c eq "\$" and substr($s, $i + 1, 1) eq "'"
$c eq "\$" substr($s, $i + 1, 1) eq "'"
MC/DC0%0/2
$c eq "\$" and substr($s, $i + 1, 1) eq "'"
$c eq "\$" substr($s, $i + 1, 1) eq "'"
Truth table66%2/3
A and B
A= $c eq "\$"B= substr($s, $i + 1, 1) eq "'"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $c eq "\$"B= substr($s, $i + 1, 1) eq "'"
ABresult
0X0
100
111
52 0 my $j = $i + 2;
53 0 ▶ $j++ while $j < $n && substr( $s, $j, 1 ) ne "'" && ( substr( $s, $j, 1 ) ne '\\' || $j++ );
Branch: 2 branches
BranchTrueFalseTotal
$j < $n and substr($s, $j, 1) ne "'" and substr($s, $j, 1) ne "\\" || $j++ and do { ++$j } 0 0 0
$j < $n and substr($s, $j, 1) ne "'" and substr($s, $j, 1) ne "\\" || $j++ and do { ++$j } 0 0 0
Condition0%0/18
$j < $n and substr($s, $j, 1) ne "'" and substr($s, $j, 1) ne "\\" || $j++
!ll&&!rl&&r
000
$j < $n and substr($s, $j, 1) ne "'"
!ll&&!rl&&r
000
substr($s, $j, 1) ne "\\" or $j++
l!l&&r!l&&!r
000
$j < $n and substr($s, $j, 1) ne "'" and substr($s, $j, 1) ne "\\" || $j++
!ll&&!rl&&r
000
$j < $n and substr($s, $j, 1) ne "'"
!ll&&!rl&&r
000
substr($s, $j, 1) ne "\\" or $j++
l!l&&r!l&&!r
000
MC/DC0%0/4
$j < $n and substr($s, $j, 1) ne "'" and substr($s, $j, 1) ne "\\" || $j++
$j < $n substr($s, $j, 1) ne "'" substr($s, $j, 1) ne "\\" $j++
MC/DC0%0/4
$j < $n and substr($s, $j, 1) ne "'" and substr($s, $j, 1) ne "\\" || $j++
$j < $n substr($s, $j, 1) ne "'" substr($s, $j, 1) ne "\\" $j++
Truth table0%0/5
A and B and C or D
A= $j < $nB= substr($s, $j, 1) ne "'"C= substr($s, $j, 1) ne "\\"D= $j++
ABCDresult
0XXX0
10XX0
11000
111X1
11011
Truth table0%0/5
A and B and C or D
A= $j < $nB= substr($s, $j, 1) ne "'"C= substr($s, $j, 1) ne "\\"D= $j++
ABCDresult
0XXX0
10XX0
11000
111X1
11011
54 0 ▶ die "bash: unexpected EOF while looking for matching `''\n" if $j >= $n;
Branch: 2 branches
BranchTrueFalseTotal
if $j >= $n 0 0 0
if $j >= $n 0 0 0
55 0 $cur .= substr( $s, $i, $j - $i + 1 );
56 0 $i = $j + 1;
57 0 next;
58 }
59 0 ▶ my $wordstart = $cur eq '' || $cur =~ /\s\z/ || $cur =~ /[;&|(]\z/;
Condition50%6/12
$cur eq '' || $cur =~ /\s\z/ || $cur =~ /[;&|(]\z/
l!l&&r!l&&!r
1080916660353
$cur eq "" or $cur =~ /\s\z/
l!l&&r!l&&!r
2774803560519
$cur eq '' || $cur =~ /\s\z/ || $cur =~ /[;&|(]\z/
l!l&&r!l&&!r
000
$cur eq "" or $cur =~ /\s\z/
l!l&&r!l&&!r
000
MC/DC100%3/3
$cur eq '' || $cur =~ /\s\z/ || $cur =~ /[;&|(]\z/
$cur eq "" $cur =~ /\s\z/ $cur =~ /[;&|(]\z/
MC/DC0%0/3
$cur eq '' || $cur =~ /\s\z/ || $cur =~ /[;&|(]\z/
$cur eq "" $cur =~ /\s\z/ $cur =~ /[;&|(]\z/
Truth table100%4/4
A or B || C
A= $cur eq ""B= $cur =~ /\s\z/C= $cur =~ /[;&|(]\z/
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
A or B || C
A= $cur eq ""B= $cur =~ /\s\z/C= $cur =~ /[;&|(]\z/
ABCresult
1XX1
01X1
0011
0000
60 0 ▶ if ( $c eq '#' && $wordstart ) { # Kommentar bis zum Zeilenende
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "#" and $wordstart) 10 71318 71328
if ($c eq "#" and $wordstart) 0 0 0
Condition33%2/6
$c eq "#" and $wordstart
!ll&&!rl&&r
71318010
$c eq "#" and $wordstart
!ll&&!rl&&r
000
MC/DC50%1/2
$c eq "#" and $wordstart
$c eq "#" $wordstart
MC/DC0%0/2
$c eq "#" and $wordstart
$c eq "#" $wordstart
Truth table66%2/3
A and B
A= $c eq "#"B= $wordstart
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $c eq "#"B= $wordstart
ABresult
0X0
100
111
61 0 ▶ $i++ while $i < $n && substr( $s, $i, 1 ) ne "\n";
Branch: 2 branches
BranchTrueFalseTotal
$i < $n and substr($s, $i, 1) ne "\n" and do { ++$i } 122 10 132
$i < $n and substr($s, $i, 1) ne "\n" and do { ++$i } 0 0 0
Condition33%2/6
$i < $n and substr($s, $i, 1) ne "\n"
!ll&&!rl&&r
010122
$i < $n and substr($s, $i, 1) ne "\n"
!ll&&!rl&&r
000
MC/DC50%1/2
$i < $n and substr($s, $i, 1) ne "\n"
$i < $n substr($s, $i, 1) ne "\n"
MC/DC0%0/2
$i < $n and substr($s, $i, 1) ne "\n"
$i < $n substr($s, $i, 1) ne "\n"
Truth table66%2/3
A and B
A= $i < $nB= substr($s, $i, 1) ne "\n"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $i < $nB= substr($s, $i, 1) ne "\n"
ABresult
0X0
100
111
62 0 next;
63 }
64 0 ▶ if ( $wordstart && substr( $s, $i, 2 ) eq '[[' && substr( $s, $i + 2, 1 ) =~ /\s/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($wordstart and substr($s, $i, 2) eq "[[" and substr($s, $i + 2, 1) =~ /\s/) 3 71315 71318
if ($wordstart and substr($s, $i, 2) eq "[[" and substr($s, $i + 2, 1) =~ /\s/) 0 0 0
Condition41%5/12
$wordstart and substr($s, $i, 2) eq "[[" and substr($s, $i + 2, 1) =~ /\s/
!ll&&!rl&&r
7131503
$wordstart and substr($s, $i, 2) eq "[["
!ll&&!rl&&r
60353109623
$wordstart and substr($s, $i, 2) eq "[[" and substr($s, $i + 2, 1) =~ /\s/
!ll&&!rl&&r
000
$wordstart and substr($s, $i, 2) eq "[["
!ll&&!rl&&r
000
MC/DC66%2/3
$wordstart and substr($s, $i, 2) eq "[[" and substr($s, $i + 2, 1) =~ /\s/
$wordstart substr($s, $i, 2) eq "[[" substr($s, $i + 2, 1) =~ /\s/
MC/DC0%0/3
$wordstart and substr($s, $i, 2) eq "[[" and substr($s, $i + 2, 1) =~ /\s/
$wordstart substr($s, $i, 2) eq "[[" substr($s, $i + 2, 1) =~ /\s/
Truth table75%3/4
A and B and C
A= $wordstartB= substr($s, $i, 2) eq "[["C= substr($s, $i + 2, 1) =~ /\s/
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and C
A= $wordstartB= substr($s, $i, 2) eq "[["C= substr($s, $i + 2, 1) =~ /\s/
ABCresult
0XX0
10X0
1100
1111
65 0 my $j = index( $s, ']]', $i + 2 );
66 0 ▶ die "bash: syntax error: unexpected end of file\n" if $j < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j < 0 0 3 3
if $j < 0 0 0 0
67 0 $cur .= substr( $s, $i, $j - $i + 2 );
68 0 $i = $j + 2;
69 0 next;
70 }
71 0 ▶ if ( substr( $s, $i, 3 ) eq '<<<' ) { # Here-String: das naechste Wort
Branch: 2 branches
BranchTrueFalseTotal
if (substr($s, $i, 3) eq "<<<") 2 71313 71315
if (substr($s, $i, 3) eq "<<<") 0 0 0
72 0 my $rest = substr( $s, $i + 3 );
73 0 my ($ws) = $rest =~ /\A(\s*)/;
74 0 my $k = $i + 3 + length $ws;
75 0 my $j = $k;
76 0 ▶ while ( $j < $n && substr( $s, $j, 1 ) !~ /[\s;&|]/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j < $n and not substr($s, $j, 1) =~ /[\s;&|]/) 2 2 4
if ($j < $n and not substr($s, $j, 1) =~ /[\s;&|]/) 0 0 0
Condition33%2/6
$j < $n and not substr($s, $j, 1) =~ /[\s;&|]/
!ll&&!rl&&r
202
$j < $n and not substr($s, $j, 1) =~ /[\s;&|]/
!ll&&!rl&&r
000
MC/DC50%1/2
$j < $n and not substr($s, $j, 1) =~ /[\s;&|]/
$j < $n not substr($s, $j, 1) =~ /[\s;&|]/
MC/DC0%0/2
$j < $n and not substr($s, $j, 1) =~ /[\s;&|]/
$j < $n not substr($s, $j, 1) =~ /[\s;&|]/
Truth table66%2/3
A and not(B)
A= $j < $nB= not substr($s, $j, 1) =~ /[\s;&|]/
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $j < $nB= not substr($s, $j, 1) =~ /[\s;&|]/
ABresult
0X0
100
111
77 0 my $x = substr( $s, $j, 1 );
78 0 ▶ if ( $x eq "'" ) { my $e = index( $s, "'", $j + 1 ); $j = $e < 0 ? $n : $e + 1 }
Branch: 8 branches
BranchTrueFalseTotal
if ($x eq q[']) { } 0 2 2
elsif ($x eq '"') { } 2 0 2
elsif ($x eq '$' and substr($s, $j + 1, 1) =~ /[({]/) { } 0 0 0
$e < 0 ? : 0 0 0
if ($x eq q[']) { } 0 0 0
elsif ($x eq '"') { } 0 0 0
elsif ($x eq '$' and substr($s, $j + 1, 1) =~ /[({]/) { } 0 0 0
$e < 0 ? : 0 0 0
79 0 ▶ elsif ( $x eq '"' ) { my $e = _close_quote( $s, $j ); $j = $e < 0 ? $n : $e + 1 }
Branch: 2 branches
BranchTrueFalseTotal
$e < 0 ? : 0 2 2
$e < 0 ? : 0 0 0
80 0 ▶ elsif ( $x eq '$' && substr( $s, $j + 1, 1 ) =~ /[({]/ ) { my $e = _close_paren( $s, $j + 1 ); $j = $e < 0 ? $n : $e + 1 }
Branch: 2 branches
BranchTrueFalseTotal
$e < 0 ? : 0 0 0
$e < 0 ? : 0 0 0
Condition0%0/6
$x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
!ll&&!rl&&r
000
$x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
!ll&&!rl&&r
000
MC/DC0%0/2
$x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
$x eq "\$" substr($s, $j + 1, 1) =~ /[({]/
MC/DC0%0/2
$x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
$x eq "\$" substr($s, $j + 1, 1) =~ /[({]/
Truth table0%0/3
A and B
A= $x eq "\$"B= substr($s, $j + 1, 1) =~ /[({]/
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $x eq "\$"B= substr($s, $j + 1, 1) =~ /[({]/
ABresult
0X0
100
111
81 0 else { $j++ }
82 }
83 0 $cur .= ' ';
84 0 push @docs, { word => substr( $s, $k, $j - $k ), herestring => 1 };
85 0 $i = $j;
86 0 next;
87 }
88 0 ▶ if ( substr( $s, $i, 2 ) eq '<<' ) { # Heredoc: Text ab der naechsten Zeile
Branch: 2 branches
BranchTrueFalseTotal
if (substr($s, $i, 2) eq "<<") 8 71305 71313
if (substr($s, $i, 2) eq "<<") 0 0 0
89 my ( $dash, $q1, $q2, $plain ) = substr( $s, $i ) =~ /\A<<(-?)[ \t]*(?:'([^']*)'|"([^"]*)"|\\?([^\s;&|<>]+))/
90 0 ▶ or do { $cur .= '<<'; $i += 2; next };
Branch: 2 branches
BranchTrueFalseTotal
() = substr($s, $i) =~ /\A<<(-?)[ \t]*(?:'([^']*)'|"([^"]*)"|\\?([^\s;&|<>]+))/ or do { $cur .= '<<'; $i += 2; next } 8 0 8
() = substr($s, $i) =~ /\A<<(-?)[ \t]*(?:'([^']*)'|"([^"]*)"|\\?([^\s;&|<>]+))/ or do { $cur .= '<<'; $i += 2; next } 0 0 0
91 0 my ($all) = substr( $s, $i ) =~ /\A(<<-?[ \t]*(?:'[^']*'|"[^"]*"|\\?[^\s;&|<>]+))/;
92 0 ▶ my $quoted = defined $q1 || defined $q2 || substr( $s, $i ) =~ /\A<<-?[ \t]*\\/;
Condition33%4/12
defined $q1 || defined $q2 || substr($s, $i) =~ /\A<<-?[ \t]*\\/
l!l&&r!l&&!r
404
defined $q1 or defined $q2
l!l&&r!l&&!r
404
defined $q1 || defined $q2 || substr($s, $i) =~ /\A<<-?[ \t]*\\/
l!l&&r!l&&!r
000
defined $q1 or defined $q2
l!l&&r!l&&!r
000
MC/DC33%1/3
defined $q1 || defined $q2 || substr($s, $i) =~ /\A<<-?[ \t]*\\/
defined $q1 defined $q2 substr($s, $i) =~ /\A<<-?[ \t]*\\/
MC/DC0%0/3
defined $q1 || defined $q2 || substr($s, $i) =~ /\A<<-?[ \t]*\\/
defined $q1 defined $q2 substr($s, $i) =~ /\A<<-?[ \t]*\\/
Truth table50%2/4
A or B || C
A= defined $q1B= defined $q2C= substr($s, $i) =~ /\A<<-?[ \t]*\\/
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
A or B || C
A= defined $q1B= defined $q2C= substr($s, $i) =~ /\A<<-?[ \t]*\\/
ABCresult
1XX1
01X1
0011
0000
93 0 ▶ push @docs, { delim => $q1 // $q2 // $plain, dash => $dash, expand => !$quoted };
Condition33%4/12
($q1 // $q2) // $plain
l!l&&r!l&&!r
440
$q1 // $q2
l!l&&r!l&&!r
404
($q1 // $q2) // $plain
l!l&&r!l&&!r
000
$q1 // $q2
l!l&&r!l&&!r
000
MC/DC0%0/3
($q1 // $q2) // $plain
$q1 $q2 $plain
MC/DC0%0/3
($q1 // $q2) // $plain
$q1 $q2 $plain
Truth table50%2/4
A // B // C
A= $q1B= $q2C= $plain
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
A // B // C
A= $q1B= $q2C= $plain
ABCresult
1XX1
01X1
0011
0000
94 0 $cur .= ' ';
95 0 $i += length $all;
96 0 next;
97 }
98 0 ▶ if ( $c eq "\n" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\n") 71 71234 71305
if ($c eq "\n") 0 0 0
99 # Heredocs dieser Zeile einsammeln
100 0 $i++;
101 0 my @here;
102 0 for my $d (@docs) {
103 0 ▶ if ( $d->{herestring} ) { push @here, $d; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($d->{"herestring"}) 0 8 8
if ($d->{"herestring"}) 0 0 0
104 0 my $body = '';
105 0 ▶ while ( $i < $n ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i < $n) 25 0 25
if ($i < $n) 0 0 0
106 0 my $e = index( $s, "\n", $i );
107 0 ▶ my $line = $e < 0 ? substr( $s, $i ) : substr( $s, $i, $e - $i );
Branch: 2 branches
BranchTrueFalseTotal
$e < 0 ? : 5 20 25
$e < 0 ? : 0 0 0
108 0 ▶ $i = $e < 0 ? $n : $e + 1;
Branch: 2 branches
BranchTrueFalseTotal
$e < 0 ? : 5 20 25
$e < 0 ? : 0 0 0
109 0 my $cmp = $line;
110 0 ▶ $cmp =~ s/\A\t+// if $d->{dash};
Branch: 2 branches
BranchTrueFalseTotal
if $d->{"dash"} 4 21 25
if $d->{"dash"} 0 0 0
111 0 ▶ last if $cmp eq $d->{delim};
Branch: 2 branches
BranchTrueFalseTotal
if $cmp eq $d->{"delim"} 8 17 25
if $cmp eq $d->{"delim"} 0 0 0
112 0 ▶ $line =~ s/\A\t+// if $d->{dash};
Branch: 2 branches
BranchTrueFalseTotal
if $d->{"dash"} 2 15 17
if $d->{"dash"} 0 0 0
113 0 $body .= "$line\n";
114 }
115 0 push @here, { %$d, body => $body };
116 }
117 0 my $before = scalar @items;
118 0 $finish->("\n");
119 0 ▶ _attach( \@items, $before, \@here ) if @here;
Branch: 2 branches
BranchTrueFalseTotal
if @here 8 63 71
if @here 0 0 0
120 0 @docs = ();
121 0 next;
122 }
123 0 ▶ if ( $c eq ';' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq ";") 210 71024 71234
if ($c eq ";") 0 0 0
124 0 ▶ my $sep = substr( $s, $i, 2 ) eq ';;' ? ';;' : ';';
Branch: 2 branches
BranchTrueFalseTotal
substr($s, $i, 2) eq ';;' ? : 5 205 210
substr($s, $i, 2) eq ';;' ? : 0 0 0
125 0 my $before = scalar @items;
126 0 $finish->($sep);
127 0 ▶ _attach( \@items, $before, [ map { $_->{herestring} ? $_ : () } @docs ] ) if @docs;
Branch: 4 branches
BranchTrueFalseTotal
if @docs 0 210 210
$_->{'herestring'} ? : 0 0 0
if @docs 0 0 0
$_->{'herestring'} ? : 0 0 0
128 0 @docs = ();
129 0 $i += length $sep;
130 0 next;
131 }
132 0 ▶ if ( $c eq '&' || $c eq '|' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "&" or $c eq "|") 357 70667 71024
if ($c eq "&" or $c eq "|") 0 0 0
Condition50%3/6
$c eq "&" or $c eq "|"
l!l&&r!l&&!r
22013770667
$c eq "&" or $c eq "|"
l!l&&r!l&&!r
000
MC/DC100%2/2
$c eq "&" or $c eq "|"
$c eq "&" $c eq "|"
MC/DC0%0/2
$c eq "&" or $c eq "|"
$c eq "&" $c eq "|"
Truth table100%3/3
A or B
A= $c eq "&"B= $c eq "|"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $c eq "&"B= $c eq "|"
ABresult
1X1
011
000
133 0 my $two = substr( $s, $i, 2 );
134 0 ▶ if ( $two eq '&&' || $two eq '||' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($two eq "&&" or $two eq "||") 212 145 357
if ($two eq "&&" or $two eq "||") 0 0 0
Condition50%3/6
$two eq "&&" or $two eq "||"
l!l&&r!l&&!r
2039145
$two eq "&&" or $two eq "||"
l!l&&r!l&&!r
000
MC/DC100%2/2
$two eq "&&" or $two eq "||"
$two eq "&&" $two eq "||"
MC/DC0%0/2
$two eq "&&" or $two eq "||"
$two eq "&&" $two eq "||"
Truth table100%3/3
A or B
A= $two eq "&&"B= $two eq "||"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $two eq "&&"B= $two eq "||"
ABresult
1X1
011
000
135 0 my $before = scalar @items;
136 0 $finish->($two);
137 0 ▶ _attach( \@items, $before, [ grep { $_->{herestring} } @docs ] ) if @docs;
Branch: 2 branches
BranchTrueFalseTotal
if @docs 0 212 212
if @docs 0 0 0
138 0 @docs = ();
139 0 $i += 2;
140 0 next;
141 }
142 # & als Hintergrund (nicht >&, &>, 2>&1)
143 0 ▶ if ( $c eq '&' && $cur !~ /[<>]\z/ && substr( $s, $i + 1, 1 ) ne '>' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "&" and not $cur =~ /[<>]\z/ and substr($s, $i + 1, 1) ne ">") 1 144 145
if ($c eq "&" and not $cur =~ /[<>]\z/ and substr($s, $i + 1, 1) ne ">") 0 0 0
Condition50%6/12
$c eq "&" and not $cur =~ /[<>]\z/ and substr($s, $i + 1, 1) ne ">"
!ll&&!rl&&r
14041
$c eq "&" and not $cur =~ /[<>]\z/
!ll&&!rl&&r
128125
$c eq "&" and not $cur =~ /[<>]\z/ and substr($s, $i + 1, 1) ne ">"
!ll&&!rl&&r
000
$c eq "&" and not $cur =~ /[<>]\z/
!ll&&!rl&&r
000
MC/DC100%3/3
$c eq "&" and not $cur =~ /[<>]\z/ and substr($s, $i + 1, 1) ne ">"
$c eq "&" not $cur =~ /[<>]\z/ substr($s, $i + 1, 1) ne ">"
MC/DC0%0/3
$c eq "&" and not $cur =~ /[<>]\z/ and substr($s, $i + 1, 1) ne ">"
$c eq "&" not $cur =~ /[<>]\z/ substr($s, $i + 1, 1) ne ">"
Truth table100%4/4
A and not(B) and C
A= $c eq "&"B= not $cur =~ /[<>]\z/C= substr($s, $i + 1, 1) ne ">"
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and not(B) and C
A= $c eq "&"B= not $cur =~ /[<>]\z/C= substr($s, $i + 1, 1) ne ">"
ABCresult
0XX0
10X0
1100
1111
144 0 my $before = scalar @items;
145 0 $finish->('&');
146 0 ▶ _attach( \@items, $before, [ grep { $_->{herestring} } @docs ] ) if @docs;
Branch: 2 branches
BranchTrueFalseTotal
if @docs 0 1 1
if @docs 0 0 0
147 0 @docs = ();
148 0 $i++;
149 0 next;
150 }
151 }
152 0 $cur .= $c;
153 0 $i++;
154 }
155 0 my $before = scalar @items;
156 0 $finish->(';');
157 0 ▶ if (@docs) {
Branch: 2 branches
BranchTrueFalseTotal
if (@docs) 2 2282 2284
if (@docs) 0 0 0
158 # Heredoc ohne Zeilenende danach: leerer Text (bash warnt nur)
159 0 ▶ _attach( \@items, $before, [ map { $_->{herestring} ? $_ : { %$_, body => '' } } @docs ] );
Branch: 2 branches
BranchTrueFalseTotal
$_->{'herestring'} ? : 2 0 2
$_->{'herestring'} ? : 0 0 0
160 }
161 0 return @items;
162 }
163  
164 10 ▶sub _attach {
Subroutine _attach: called CC=5 SCAR=23.0
165 0 ▶ my ( $items, $before, $docs ) = @_;
Subroutine _attach: not called CC=5 SCAR=23.0
166 0 ▶ return unless @$items > $before && @$docs;
Branch: 2 branches
BranchTrueFalseTotal
unless @$items > $before and @$docs 0 10 10
unless @$items > $before and @$docs 0 0 0
Condition16%1/6
@$items > $before and @$docs
!ll&&!rl&&r
0010
@$items > $before and @$docs
!ll&&!rl&&r
000
MC/DC0%0/2
@$items > $before and @$docs
@$items > $before @$docs
MC/DC0%0/2
@$items > $before and @$docs
@$items > $before @$docs
Truth table33%1/3
A and B
A= @$items > $beforeB= @$docs
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= @$items > $beforeB= @$docs
ABresult
0X0
100
111
167 0 my $it = $items->[-1];
168 0 my $d = $docs->[-1]; # mehrere Heredocs an einem Befehl: der letzte ist die Eingabe
169 0 ▶ if ( $d->{herestring} ) { $it->{herestring} = $d->{word} }
Branch: 2 branches
BranchTrueFalseTotal
if ($d->{'herestring'}) { } 2 8 10
if ($d->{'herestring'}) { } 0 0 0
170 0 ▶ else { $it->{heredoc} = $d->{body}; $it->{expand_doc} = $d->{expand} ? 1 : 0 }
Branch: 2 branches
BranchTrueFalseTotal
$d->{'expand'} ? : 4 4 8
$d->{'expand'} ? : 0 0 0
171 0 return;
172 }
173  
174 # Ende eines "…" bzw. `…` ab Position $i (Backslash, $( ) darin)
175 263 ▶sub _close_quote {
Subroutine _close_quote: called CC=11 SCAR=36.2
176 0 ▶ my ( $s, $i ) = @_;
Subroutine _close_quote: not called CC=11 SCAR=36.2
177 0 my $q = substr( $s, $i, 1 );
178 0 my $j = $i + 1;
179 0 ▶ while ( $j < length $s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j < length $s) 7223 1 7224
if ($j < length $s) 0 0 0
180 0 my $x = substr( $s, $j, 1 );
181 0 ▶ return $j if $x eq $q;
Branch: 2 branches
BranchTrueFalseTotal
if $x eq $q 262 6961 7223
if $x eq $q 0 0 0
182 0 ▶ if ( $x eq '\\' ) { $j += 2; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($x eq "\\") 5 6956 6961
if ($x eq "\\") 0 0 0
183 0 ▶ if ( $q eq '"' && $x eq '$' && substr( $s, $j + 1, 1 ) =~ /[({]/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($q eq "\"" and $x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/) 14 6942 6956
if ($q eq "\"" and $x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/) 0 0 0
Condition50%6/12
$q eq "\"" and $x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
!ll&&!rl&&r
68905214
$q eq "\"" and $x eq "\$"
!ll&&!rl&&r
16687466
$q eq "\"" and $x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
!ll&&!rl&&r
000
$q eq "\"" and $x eq "\$"
!ll&&!rl&&r
000
MC/DC100%3/3
$q eq "\"" and $x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
$q eq "\"" $x eq "\$" substr($s, $j + 1, 1) =~ /[({]/
MC/DC0%0/3
$q eq "\"" and $x eq "\$" and substr($s, $j + 1, 1) =~ /[({]/
$q eq "\"" $x eq "\$" substr($s, $j + 1, 1) =~ /[({]/
Truth table100%4/4
A and B and C
A= $q eq "\""B= $x eq "\$"C= substr($s, $j + 1, 1) =~ /[({]/
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and C
A= $q eq "\""B= $x eq "\$"C= substr($s, $j + 1, 1) =~ /[({]/
ABCresult
0XX0
10X0
1100
1111
184 0 my $e = _close_paren( $s, $j + 1 );
185 0 ▶ return -1 if $e < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $e < 0 0 14 14
if $e < 0 0 0 0
186 0 $j = $e + 1;
187 0 next;
188 }
189 0 ▶ if ( $q eq '"' && $x eq '`' ) { my $e = _close_quote( $s, $j ); return -1 if $e < 0; $j = $e + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($q eq "\"" and $x eq "`") 0 6942 6942
if $e < 0 0 0 0
if ($q eq "\"" and $x eq "`") 0 0 0
if $e < 0 0 0 0
Condition33%2/6
$q eq "\"" and $x eq "`"
!ll&&!rl&&r
1669260
$q eq "\"" and $x eq "`"
!ll&&!rl&&r
000
MC/DC0%0/2
$q eq "\"" and $x eq "`"
$q eq "\"" $x eq "`"
MC/DC0%0/2
$q eq "\"" and $x eq "`"
$q eq "\"" $x eq "`"
Truth table66%2/3
A and B
A= $q eq "\""B= $x eq "`"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $q eq "\""B= $x eq "`"
ABresult
0X0
100
111
190 0 $j++;
191 }
192 0 return -1;
193 }
194  
195 # Ende der Klammer ( bzw. { ab Position $i (verschachtelt, Anfuehrungszeichen darin)
196 104 ▶sub _close_paren {
Subroutine _close_paren: called CC=12 SCAR=39.4
197 0 ▶ my ( $s, $i ) = @_;
Subroutine _close_paren: not called CC=12 SCAR=39.4
198 0 my $open = substr( $s, $i, 1 );
199 0 ▶ my $close = $open eq '(' ? ')' : '}';
Branch: 2 branches
BranchTrueFalseTotal
$open eq '(' ? : 42 62 104
$open eq '(' ? : 0 0 0
200 0 my ( $d, $j ) = ( 0, $i );
201 0 ▶ while ( $j < length $s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j < length $s) 1208 0 1208
if ($j < length $s) 0 0 0
202 0 my $x = substr( $s, $j, 1 );
203 0 ▶ if ( $x eq "'" && $open eq '(' ) { my $e = index( $s, "'", $j + 1 ); return -1 if $e < 0; $j = $e + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($x eq "'" and $open eq "(") 2 1206 1208
if $e < 0 0 2 2
if ($x eq "'" and $open eq "(") 0 0 0
if $e < 0 0 0 0
Condition33%2/6
$x eq "'" and $open eq "("
!ll&&!rl&&r
120602
$x eq "'" and $open eq "("
!ll&&!rl&&r
000
MC/DC50%1/2
$x eq "'" and $open eq "("
$x eq "'" $open eq "("
MC/DC0%0/2
$x eq "'" and $open eq "("
$x eq "'" $open eq "("
Truth table66%2/3
A and B
A= $x eq "'"B= $open eq "("
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $x eq "'"B= $open eq "("
ABresult
0X0
100
111
204 0 ▶ if ( $x eq '"' ) { my $e = _close_quote( $s, $j ); return -1 if $e < 0; $j = $e + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($x eq "\"") 0 1206 1206
if $e < 0 0 0 0
if ($x eq "\"") 0 0 0
if $e < 0 0 0 0
205 0 ▶ if ( $x eq '\\' ) { $j += 2; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($x eq "\\") 0 1206 1206
if ($x eq "\\") 0 0 0
206 0 ▶ if ( $x eq $open ) { $d++ }
Branch: 4 branches
BranchTrueFalseTotal
if ($x eq $open) { } 131 1075 1206
elsif ($x eq $close) { } 131 944 1075
if ($x eq $open) { } 0 0 0
elsif ($x eq $close) { } 0 0 0
207 0 ▶ elsif ( $x eq $close ) { return $j unless --$d }
Branch: 2 branches
BranchTrueFalseTotal
unless --$d 104 27 131
unless --$d 0 0 0
208 0 $j++;
209 }
210 0 return -1;
211 }
212  
213  
214 4 ▶sub top_pipe {
Subroutine top_pipe: called CC=16 SCAR=45.0
Pod documented
215 0 ▶ my ($s) = @_;
Subroutine top_pipe: not called CC=16 SCAR=45.0
Pod documented
216 0 my @at;
217 0 my $i = 0;
218 0 ▶ while ( $i < length $s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i < length $s) 139 4 143
if ($i < length $s) 0 0 0
219 0 my $c = substr( $s, $i, 1 );
220 0 ▶ if ( $c eq "'" ) { my $j = index( $s, "'", $i + 1 ); last if $j < 0; $i = $j + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq "'") 1 138 139
if $j < 0 0 1 1
if ($c eq "'") 0 0 0
if $j < 0 0 0 0
221 0 ▶ if ( $c eq '"' || $c eq '`' ) { my $j = _close_quote( $s, $i ); last if $j < 0; $i = $j + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq "\"" or $c eq "`") 1 137 138
if $j < 0 0 1 1
if ($c eq "\"" or $c eq "`") 0 0 0
if $j < 0 0 0 0
Condition33%2/6
$c eq "\"" or $c eq "`"
l!l&&r!l&&!r
10137
$c eq "\"" or $c eq "`"
l!l&&r!l&&!r
000
MC/DC50%1/2
$c eq "\"" or $c eq "`"
$c eq "\"" $c eq "`"
MC/DC0%0/2
$c eq "\"" or $c eq "`"
$c eq "\"" $c eq "`"
Truth table66%2/3
A or B
A= $c eq "\""B= $c eq "`"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $c eq "\""B= $c eq "`"
ABresult
1X1
011
000
222 0 ▶ if ( $c eq '\\' ) { $i += 2; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\\") 0 137 137
if ($c eq "\\") 0 0 0
223 0 ▶ if ( $c eq '$' && substr( $s, $i + 1, 1 ) =~ /[({]/ ) { my $j = _close_paren( $s, $i + 1 ); last if $j < 0; $i = $j + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/) 0 137 137
if $j < 0 0 0 0
if ($c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/) 0 0 0
if $j < 0 0 0 0
Condition16%1/6
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
!ll&&!rl&&r
13700
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
!ll&&!rl&&r
000
MC/DC0%0/2
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
$c eq "\$" substr($s, $i + 1, 1) =~ /[({]/
MC/DC0%0/2
$c eq "\$" and substr($s, $i + 1, 1) =~ /[({]/
$c eq "\$" substr($s, $i + 1, 1) =~ /[({]/
Truth table33%1/3
A and B
A= $c eq "\$"B= substr($s, $i + 1, 1) =~ /[({]/
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $c eq "\$"B= substr($s, $i + 1, 1) =~ /[({]/
ABresult
0X0
100
111
224 0 ▶ push @at, $i if $c eq '|' && substr( $s, $i + 1, 1 ) ne '|' && ( $i == 0 || substr( $s, $i - 1, 1 ) ne '|' );
Branch: 2 branches
BranchTrueFalseTotal
if $c eq "|" and substr($s, $i + 1, 1) ne "|" and $i == 0 || substr($s, $i - 1, 1) ne "|" 4 133 137
if $c eq "|" and substr($s, $i + 1, 1) ne "|" and $i == 0 || substr($s, $i - 1, 1) ne "|" 0 0 0
Condition27%5/18
$c eq "|" and substr($s, $i + 1, 1) ne "|" and $i == 0 || substr($s, $i - 1, 1) ne "|"
!ll&&!rl&&r
13304
$c eq "|" and substr($s, $i + 1, 1) ne "|"
!ll&&!rl&&r
13304
$i == 0 or substr($s, $i - 1, 1) ne "|"
l!l&&r!l&&!r
040
$c eq "|" and substr($s, $i + 1, 1) ne "|" and $i == 0 || substr($s, $i - 1, 1) ne "|"
!ll&&!rl&&r
000
$c eq "|" and substr($s, $i + 1, 1) ne "|"
!ll&&!rl&&r
000
$i == 0 or substr($s, $i - 1, 1) ne "|"
l!l&&r!l&&!r
000
MC/DC25%1/4
$c eq "|" and substr($s, $i + 1, 1) ne "|" and $i == 0 || substr($s, $i - 1, 1) ne "|"
$c eq "|" substr($s, $i + 1, 1) ne "|" $i == 0 substr($s, $i - 1, 1) ne "|"
MC/DC0%0/4
$c eq "|" and substr($s, $i + 1, 1) ne "|" and $i == 0 || substr($s, $i - 1, 1) ne "|"
$c eq "|" substr($s, $i + 1, 1) ne "|" $i == 0 substr($s, $i - 1, 1) ne "|"
Truth table40%2/5
A and B and C or D
A= $c eq "|"B= substr($s, $i + 1, 1) ne "|"C= $i == 0D= substr($s, $i - 1, 1) ne "|"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
Truth table0%0/5
A and B and C or D
A= $c eq "|"B= substr($s, $i + 1, 1) ne "|"C= $i == 0D= substr($s, $i - 1, 1) ne "|"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
225 0 $i++;
226 }
227 0 ▶ return () unless @at;
Branch: 2 branches
BranchTrueFalseTotal
unless @at 0 4 4
unless @at 0 0 0
228 0 return ( substr( $s, 0, $at[-1] ), substr( $s, $at[-1] + 1 ) );
229 }
230  
231 # --- Bloecke ---------------------------------------------------------------------
232  
233  
234 84 my $KW = qr/(?:if|then|elif|else|fi|for|while|until|do|done|case|esac|function|select|\{|\}|\(|\(\(|break|continue)/;
235  
236 2279 ▶sub parse {
Subroutine parse: called CC=3 SCAR=14.8
Pod documented
237 0 ▶ my ($items) = @_;
Subroutine parse: not called CC=3 SCAR=14.8
Pod documented
238 0 my @it = map { {%$_} } @$items;
239 0 my ( $nodes, $stop ) = eval { _parse_list( \@it, {} ) };
240 0 ▶ if ( my $e = $@ ) { $e =~ s/\s+\z//; return $e }
Branch: 2 branches
BranchTrueFalseTotal
if (my $e = $@) 4 2275 2279
if (my $e = $@) 0 0 0
241 0 ▶ return "bash: syntax error near unexpected token `$stop->{word}'" if $stop;
Branch: 2 branches
BranchTrueFalseTotal
if $stop 0 2275 2275
if $stop 0 0 0
242 0 return $nodes;
243 }
244  
245 # naechstes Glied, ein fuehrendes Schluesselwort mit Rest (then echo a) abgespalten
246 2808 ▶sub _next {
Subroutine _next: called CC=4 SCAR=18.7
247 0 ▶ my ($it) = @_;
Subroutine _next: not called CC=4 SCAR=18.7
248 0 ▶ my $x = shift @$it or return;
Branch: 2 branches
BranchTrueFalseTotal
my $x = shift @$it or return 2808 0 2808
my $x = shift @$it or return 0 0 0
249 0 ▶ if ( $x->{raw} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s && $1 ne 'elif' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s and $1 ne "elif") 32 2776 2808
if ($x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s and $1 ne "elif") 0 0 0
Condition50%3/6
$x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s and $1 ne "elif"
!ll&&!rl&&r
2774232
$x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s and $1 ne "elif"
!ll&&!rl&&r
000
MC/DC100%2/2
$x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s and $1 ne "elif"
$x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s $1 ne "elif"
MC/DC0%0/2
$x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s and $1 ne "elif"
$x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/s $1 ne "elif"
Truth table100%3/3
A and B
A= $x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/sB= $1 ne "elif"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $x->{"raw"} =~ /\A(then|else|do|elif)\s+(\S.*)\z/sB= $1 ne "elif"
ABresult
0X0
100
111
250 0 unshift @$it, { %$x, raw => $2, op => ';' };
251 0 return { %$x, raw => $1 };
252 }
253 0 return $x;
254 }
255  
256 2803 ▶sub _kw {
Subroutine _kw: called CC=4 SCAR=17.9
257 0 ▶ my ($x) = @_;
Subroutine _kw: not called CC=4 SCAR=17.9
258 return $x->{raw} =~ /\A(if|then|elif|else|fi|for|while|until|do|done|case|esac|function|select)(?=\s|\z|;)/ ? $1
259 : $x->{raw} =~ /\A(\{|\}|\(\(|\()/ ? $1
260 0 ▶ : $x->{raw} =~ /\A[A-Za-z_][\w-]*\s*\(\)/ ? 'function'
Branch: 6 branches
BranchTrueFalseTotal
$x->{'raw'} =~ /\A(if|then|elif|else|fi|for|while|until|do|done|case|esac|function|select)(?=\s|\z|;)/ ? : 99 2704 2803
$x->{'raw'} =~ /\A(\{|\}|\(\(|\()/ ? : 17 2687 2704
$x->{'raw'} =~ /\A[A-Za-z_][\w-]*\s*\(\)/ ? : 5 2682 2687
$x->{'raw'} =~ /\A(if|then|elif|else|fi|for|while|until|do|done|case|esac|function|select)(?=\s|\z|;)/ ? : 0 0 0
$x->{'raw'} =~ /\A(\{|\}|\(\(|\()/ ? : 0 0 0
$x->{'raw'} =~ /\A[A-Za-z_][\w-]*\s*\(\)/ ? : 0 0 0
261 : undef;
262 }
263  
264 2353 ▶sub _parse_list {
Subroutine _parse_list: called CC=77 SCAR=73.5
265 0 ▶ my ( $it, $stops ) = @_;
Subroutine _parse_list: not called CC=77 SCAR=73.5
266 0 my @nodes;
267 0 ▶ while (@$it) {
Branch: 2 branches
BranchTrueFalseTotal
if (@$it) 2787 2288 5075
if (@$it) 0 0 0
268 0 my $x = _next($it);
269 0 ▶ my $kw = _kw($x) // '';
Condition50%2/4
_kw($x) // ""
l!l
1072680
_kw($x) // ""
l!l
00
MC/DC100%1/1
_kw($x) // ""
_kw($x)
MC/DC0%0/1
_kw($x) // ""
_kw($x)
Truth table100%2/2
A
A= _kw($x)
Aresult
11
00
Truth table0%0/2
A
A= _kw($x)
Aresult
11
00
270 0 ▶ if ( $stops->{$kw} ) { return ( \@nodes, { word => $kw, item => $x } ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($stops->{$kw}) 61 2726 2787
if ($stops->{$kw}) 0 0 0
271 0 ▶ if ( $kw eq 'if' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "if") 7 2719 2726
if ($kw eq "if") 0 0 0
272 0 ▶ unshift @$it, { %$x, raw => substr( $x->{raw}, 2 ) =~ s/\A\s+//r, op => ';' } if $x->{raw} =~ /\Aif\s+\S/;
Branch: 2 branches
BranchTrueFalseTotal
if $x->{"raw"} =~ /\Aif\s+\S/ 7 0 7
if $x->{"raw"} =~ /\Aif\s+\S/ 0 0 0
273 0 my @arms;
274 my $else;
275 0 while (1) {
276 0 my ( $cond, $s1 ) = _parse_list( $it, { then => 1 } );
277 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s1;
Branch: 2 branches
BranchTrueFalseTotal
unless $s1 0 9 9
unless $s1 0 0 0
278 0 ▶ die "bash: syntax error near unexpected token `then'\n" unless @$cond;
Branch: 2 branches
BranchTrueFalseTotal
unless @$cond 0 9 9
unless @$cond 0 0 0
279 0 my ( $body, $s2 ) = _parse_list( $it, { elif => 1, else => 1, fi => 1 } );
280 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s2;
Branch: 2 branches
BranchTrueFalseTotal
unless $s2 2 7 9
unless $s2 0 0 0
281 0 push @arms, [ $cond, $body ];
282 0 ▶ if ( $s2->{word} eq 'elif' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s2->{"word"} eq "elif") 2 5 7
if ($s2->{"word"} eq "elif") 0 0 0
283 0 ( my $r = $s2->{item}{raw} ) =~ s/\Aelif\s*//;
284 0 ▶ unshift @$it, { %{ $s2->{item} }, raw => $r, op => ';' } if length $r;
Branch: 2 branches
BranchTrueFalseTotal
if length $r 2 0 2
if length $r 0 0 0
285 0 next;
286 }
287 0 ▶ if ( $s2->{word} eq 'else' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s2->{"word"} eq "else") 2 3 5
if ($s2->{"word"} eq "else") 0 0 0
288 0 my ( $eb, $s3 ) = _parse_list( $it, { fi => 1 } );
289 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s3;
Branch: 2 branches
BranchTrueFalseTotal
unless $s3 0 2 2
unless $s3 0 0 0
290 0 $else = $eb;
291 0 $s2 = $s3;
292 }
293 0 push @nodes, { type => 'if', op => $x->{op}, arms => \@arms, else => $else, post => _post( $s2->{item}, 'fi' ) };
294 0 last;
295 }
296 0 next;
297 }
298 0 ▶ if ( $kw eq 'for' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "for") 16 2703 2719
if ($kw eq "for") 0 0 0
299 0 ▶ if ( $x->{raw} =~ /\Afor\s*\(\(/ ) { push @nodes, _skip_block( $it, $x ); next }
Branch: 2 branches
BranchTrueFalseTotal
if ($x->{"raw"} =~ /\Afor\s*\(\(/) 0 16 16
if ($x->{"raw"} =~ /\Afor\s*\(\(/) 0 0 0
300 my ( $var, $words ) = $x->{raw} =~ /\Afor\s+([A-Za-z_]\w*)(?:\s+in\b\s*(.*))?\z/s
301 0 ▶ or die "bash: syntax error near unexpected token `" . ( split ' ', $x->{raw} )[1] . "'\n";
Branch: 2 branches
BranchTrueFalseTotal
() = $x->{"raw"} =~ /\Afor\s+([A-Za-z_]\w*)(?:\s+in\b\s*(.*))?\z/s or die 'bash: syntax error near unexpected token `' . (split(' ', $x->{"raw"}, 0))[1] . "'\n" 16 0 16
() = $x->{"raw"} =~ /\Afor\s+([A-Za-z_]\w*)(?:\s+in\b\s*(.*))?\z/s or die 'bash: syntax error near unexpected token `' . (split(' ', $x->{"raw"}, 0))[1] . "'\n" 0 0 0
302 0 ▶ my $do = _next($it) or die "bash: syntax error: unexpected end of file\n";
Branch: 2 branches
BranchTrueFalseTotal
my $do = _next($it) or die "bash: syntax error: unexpected end of file\n" 16 0 16
my $do = _next($it) or die "bash: syntax error: unexpected end of file\n" 0 0 0
303 0 ▶ die "bash: syntax error near unexpected token `" . ( split ' ', $do->{raw} )[0] . "'\n" unless ( _kw($do) // '' ) eq 'do';
Branch: 2 branches
BranchTrueFalseTotal
unless (_kw($do) // "") eq "do" 2 14 16
unless (_kw($do) // "") eq "do" 0 0 0
Condition50%2/4
_kw($do) // ""
l!l
142
_kw($do) // ""
l!l
00
MC/DC100%1/1
_kw($do) // ""
_kw($do)
MC/DC0%0/1
_kw($do) // ""
_kw($do)
Truth table100%2/2
A
A= _kw($do)
Aresult
11
00
Truth table0%0/2
A
A= _kw($do)
Aresult
11
00
304 0 my ( $body, $s ) = _parse_list( $it, { done => 1 } );
305 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s;
Branch: 2 branches
BranchTrueFalseTotal
unless $s 0 14 14
unless $s 0 0 0
306 0 ▶ die "bash: syntax error near unexpected token `done'\n" unless @$body;
Branch: 2 branches
BranchTrueFalseTotal
unless @$body 0 14 14
unless @$body 0 0 0
307 0 ▶ push @nodes, { type => 'for', op => $x->{op}, var => $var, words => $words // '"$@"', body => $body, post => _post( $s->{item}, 'done' ) };
Condition25%1/4
$words // "\"\$\@\""
l!l
140
$words // "\"\$\@\""
l!l
00
MC/DC0%0/1
$words // "\"\$\@\""
$words
MC/DC0%0/1
$words // "\"\$\@\""
$words
Truth table50%1/2
A
A= $words
Aresult
11
00
Truth table0%0/2
A
A= $words
Aresult
11
00
308 0 next;
309 }
310 0 ▶ if ( $kw eq 'while' || $kw eq 'until' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "while" or $kw eq "until") 6 2697 2703
if ($kw eq "while" or $kw eq "until") 0 0 0
Condition50%3/6
$kw eq "while" or $kw eq "until"
l!l&&r!l&&!r
512697
$kw eq "while" or $kw eq "until"
l!l&&r!l&&!r
000
MC/DC100%2/2
$kw eq "while" or $kw eq "until"
$kw eq "while" $kw eq "until"
MC/DC0%0/2
$kw eq "while" or $kw eq "until"
$kw eq "while" $kw eq "until"
Truth table100%3/3
A or B
A= $kw eq "while"B= $kw eq "until"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $kw eq "while"B= $kw eq "until"
ABresult
1X1
011
000
311 0 ( my $r = $x->{raw} ) =~ s/\A\Q$kw\E\s*//;
312 0 ▶ unshift @$it, { %$x, raw => $r, op => ';' } if length $r;
Branch: 2 branches
BranchTrueFalseTotal
if length $r 6 0 6
if length $r 0 0 0
313 0 my ( $cond, $s1 ) = _parse_list( $it, { do => 1 } );
314 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s1;
Branch: 2 branches
BranchTrueFalseTotal
unless $s1 0 6 6
unless $s1 0 0 0
315 0 my ( $body, $s2 ) = _parse_list( $it, { done => 1 } );
316 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s2;
Branch: 2 branches
BranchTrueFalseTotal
unless $s2 0 6 6
unless $s2 0 0 0
317 0 ▶ die "bash: syntax error near unexpected token `done'\n" unless @$body;
Branch: 2 branches
BranchTrueFalseTotal
unless @$body 0 6 6
unless @$body 0 0 0
318 0 ▶ push @nodes, { type => 'while', op => $x->{op}, until => $kw eq 'until' ? 1 : 0, cond => $cond, body => $body, post => _post( $s2->{item}, 'done' ) };
Branch: 2 branches
BranchTrueFalseTotal
$kw eq 'until' ? : 1 5 6
$kw eq 'until' ? : 0 0 0
319 0 next;
320 }
321 0 ▶ if ( $x->{raw} =~ /\|\s*(?:while|until)\b/ && ( my ( $left, $right ) = top_pipe( $x->{raw} ) ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($x->{"raw"} =~ /\|\s*(?:while|until)\b/ and () = top_pipe($x->{"raw"})) 4 2693 2697
if ($x->{"raw"} =~ /\|\s*(?:while|until)\b/ and () = top_pipe($x->{"raw"})) 0 0 0
Condition33%2/6
$x->{"raw"} =~ /\|\s*(?:while|until)\b/ and () = top_pipe($x->{"raw"})
!ll&&!rl&&r
269304
$x->{"raw"} =~ /\|\s*(?:while|until)\b/ and () = top_pipe($x->{"raw"})
!ll&&!rl&&r
000
MC/DC50%1/2
$x->{"raw"} =~ /\|\s*(?:while|until)\b/ and () = top_pipe($x->{"raw"})
$x->{"raw"} =~ /\|\s*(?:while|until)\b/ () = top_pipe($x->{"raw"})
MC/DC0%0/2
$x->{"raw"} =~ /\|\s*(?:while|until)\b/ and () = top_pipe($x->{"raw"})
$x->{"raw"} =~ /\|\s*(?:while|until)\b/ () = top_pipe($x->{"raw"})
Truth table66%2/3
A and B
A= $x->{"raw"} =~ /\|\s*(?:while|until)\b/B= () = top_pipe($x->{"raw"})
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $x->{"raw"} =~ /\|\s*(?:while|until)\b/B= () = top_pipe($x->{"raw"})
ABresult
0X0
100
111
322 0 ▶ if ( $right =~ /\A\s*(while|until)\b/ ) { # befehl | while …; do …; done
Branch: 2 branches
BranchTrueFalseTotal
if ($right =~ /\A\s*(while|until)\b/) 4 0 4
if ($right =~ /\A\s*(while|until)\b/) 0 0 0
323 0 ( my $r = $right ) =~ s/\A\s*(?:while|until)\s*//;
324 0 my $kw2 = $1;
325 0 ▶ unshift @$it, { %$x, raw => $r, op => ';' } if length $r;
Branch: 2 branches
BranchTrueFalseTotal
if length $r 4 0 4
if length $r 0 0 0
326 0 my ( $cond, $s1 ) = _parse_list( $it, { do => 1 } );
327 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s1;
Branch: 2 branches
BranchTrueFalseTotal
unless $s1 0 4 4
unless $s1 0 0 0
328 0 my ( $body, $s2 ) = _parse_list( $it, { done => 1 } );
329 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s2;
Branch: 2 branches
BranchTrueFalseTotal
unless $s2 0 4 4
unless $s2 0 0 0
330 0 push @nodes, { type => 'while', op => $x->{op}, until => 0, input_cmd => $left, cond => $cond, body => $body, post => _post( $s2->{item}, 'done' ) };
331 0 next;
332 }
333 }
334 0 ▶ if ( $kw eq 'case' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "case") 2 2691 2693
if ($kw eq "case") 0 0 0
335 0 ▶ my ( $word ) = $x->{raw} =~ /\Acase\s+(.+?)\s+in\b/s or die "bash: syntax error near unexpected token `" . ( split ' ', $x->{raw} )[-1] . "'\n";
Branch: 2 branches
BranchTrueFalseTotal
my($word) = $x->{"raw"} =~ /\Acase\s+(.+?)\s+in\b/s or die 'bash: syntax error near unexpected token `' . (split(' ', $x->{"raw"}, 0))[-1] . "'\n" 2 0 2
my($word) = $x->{"raw"} =~ /\Acase\s+(.+?)\s+in\b/s or die 'bash: syntax error near unexpected token `' . (split(' ', $x->{"raw"}, 0))[-1] . "'\n" 0 0 0
336 0 ( my $rest = $x->{raw} ) =~ s/\Acase\s+.+?\s+in\b\s*//s;
337 0 my @arms;
338 my $cur;
339 0 ▶ my @queue = length $rest ? ( { %$x, raw => $rest, op => ';' } ) : ();
Branch: 2 branches
BranchTrueFalseTotal
length $rest ? : 2 0 2
length $rest ? : 0 0 0
340 0 while (1) {
341 0 ▶ my $y = @queue ? shift @queue : _next($it);
Branch: 2 branches
BranchTrueFalseTotal
@queue ? : 2 5 7
@queue ? : 0 0 0
342 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $y;
Branch: 2 branches
BranchTrueFalseTotal
unless $y 0 7 7
unless $y 0 0 0
343 0 ▶ if ( $y->{raw} =~ /\Aesac\b\s*(.*)\z/s ) { push @arms, $cur if $cur; push @nodes, { type => 'case', op => $x->{op}, word => $word, arms => \@arms, post => $1 }; last }
Branch: 4 branches
BranchTrueFalseTotal
if ($y->{"raw"} =~ /\Aesac\b\s*(.*)\z/s) 2 5 7
if $cur 0 2 2
if ($y->{"raw"} =~ /\Aesac\b\s*(.*)\z/s) 0 0 0
if $cur 0 0 0
344 0 ▶ if ( !$cur ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $cur) { } 5 0 5
if (not $cur) { } 0 0 0
345 my ( $pats, $after ) = $y->{raw} =~ /\A\(?\s*((?:[^)\\]|\\.)*?)\s*\)\s*(.*)\z/s
346 0 ▶ or die "bash: syntax error near unexpected token `" . ( split ' ', $y->{raw} )[0] . "'\n";
Branch: 2 branches
BranchTrueFalseTotal
() = $y->{"raw"} =~ /\A\(?\s*((?:[^)\\]|\\.)*?)\s*\)\s*(.*)\z/s or die 'bash: syntax error near unexpected token `' . (split(' ', $y->{"raw"}, 0))[0] . "'\n" 5 0 5
() = $y->{"raw"} =~ /\A\(?\s*((?:[^)\\]|\\.)*?)\s*\)\s*(.*)\z/s or die 'bash: syntax error near unexpected token `' . (split(' ', $y->{"raw"}, 0))[0] . "'\n" 0 0 0
347 0 $cur = { pats => [ _split_pats($pats) ], items => [] };
348 0 ▶ push @{ $cur->{items} }, { %$y, raw => $after, op => ';' } if length $after;
Branch: 2 branches
BranchTrueFalseTotal
if length $after 5 0 5
if length $after 0 0 0
349 }
350 0 ▶ else { push @{ $cur->{items} }, $y if length $y->{raw} }
Branch: 2 branches
BranchTrueFalseTotal
if length $y->{"raw"} 0 0 0
if length $y->{"raw"} 0 0 0
351 0 ▶ if ( ( $y->{sep} // '' ) eq ';;' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (($y->{"sep"} // "") eq ";;") 5 0 5
if (($y->{"sep"} // "") eq ";;") 0 0 0
Condition25%1/4
$y->{"sep"} // ""
l!l
50
$y->{"sep"} // ""
l!l
00
MC/DC0%0/1
$y->{"sep"} // ""
$y->{"sep"}
MC/DC0%0/1
$y->{"sep"} // ""
$y->{"sep"}
Truth table50%1/2
A
A= $y->{"sep"}
Aresult
11
00
Truth table0%0/2
A
A= $y->{"sep"}
Aresult
11
00
352 0 my ( $body, $s ) = _parse_list( [ @{ $cur->{items} } ], {} );
353 0 ▶ die "bash: syntax error near unexpected token `$s->{word}'\n" if $s;
Branch: 2 branches
BranchTrueFalseTotal
if $s 0 5 5
if $s 0 0 0
354 0 push @arms, { pats => $cur->{pats}, body => $body };
355 0 $cur = undef;
356 }
357 }
358 # letzter Zweig ohne ;; vor esac
359 0 ▶ if ( my $last = $nodes[-1]{arms}[-1] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $last = $nodes[-1]{"arms"}[-1]) 2 0 2
if (my $last = $nodes[-1]{"arms"}[-1]) 0 0 0
360 0 ▶ if ( ref $last eq 'HASH' && $last->{items} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $last eq "HASH" and $last->{"items"}) 0 2 2
if (ref $last eq "HASH" and $last->{"items"}) 0 0 0
Condition16%1/6
ref $last eq "HASH" and $last->{"items"}
!ll&&!rl&&r
020
ref $last eq "HASH" and $last->{"items"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $last eq "HASH" and $last->{"items"}
ref $last eq "HASH" $last->{"items"}
MC/DC0%0/2
ref $last eq "HASH" and $last->{"items"}
ref $last eq "HASH" $last->{"items"}
Truth table33%1/3
A and B
A= ref $last eq "HASH"B= $last->{"items"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $last eq "HASH"B= $last->{"items"}
ABresult
0X0
100
111
361 0 my ( $body, $s ) = _parse_list( [ @{ $last->{items} } ], {} );
362 0 $nodes[-1]{arms}[-1] = { pats => $last->{pats}, body => $body };
363 }
364 }
365 0 next;
366 }
367 0 ▶ if ( $kw eq '{' && $x->{raw} =~ /\A\{(?:\s+(.*))?\z/s ) { # { liste; } [> datei | filter]
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "{" and $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s) 2 2689 2691
if ($kw eq "{" and $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s) 0 0 0
Condition33%2/6
$kw eq "{" and $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
!ll&&!rl&&r
268902
$kw eq "{" and $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
!ll&&!rl&&r
000
MC/DC50%1/2
$kw eq "{" and $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
$kw eq "{" $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
MC/DC0%0/2
$kw eq "{" and $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
$kw eq "{" $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
Truth table66%2/3
A and B
A= $kw eq "{"B= $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $kw eq "{"B= $x->{"raw"} =~ /\A\{(?:\s+(.*))?\z/s
ABresult
0X0
100
111
368 0 ▶ unshift @$it, { %$x, raw => $1, op => ';' } if defined $1 && length $1;
Branch: 2 branches
BranchTrueFalseTotal
if defined $1 and length $1 2 0 2
if defined $1 and length $1 0 0 0
Condition16%1/6
defined $1 and length $1
!ll&&!rl&&r
002
defined $1 and length $1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $1 and length $1
defined $1 length $1
MC/DC0%0/2
defined $1 and length $1
defined $1 length $1
Truth table33%1/3
A and B
A= defined $1B= length $1
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $1B= length $1
ABresult
0X0
100
111
369 0 my ( $body, $s ) = _parse_list( $it, { '}' => 1 } );
370 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s;
Branch: 2 branches
BranchTrueFalseTotal
unless $s 0 2 2
unless $s 0 0 0
371 0 push @nodes, { type => 'group', op => $x->{op}, body => $body, post => _post( $s->{item}, '}' ) };
372 0 next;
373 }
374 0 ▶ if ( $kw eq '(' && ( my $sub = _subshell( $it, $x ) ) ) { push @nodes, $sub; next } # ( liste ) [| filter | > datei]
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "(" and my $sub = _subshell($it, $x)) 6 2683 2689
if ($kw eq "(" and my $sub = _subshell($it, $x)) 0 0 0
Condition33%2/6
$kw eq "(" and my $sub = _subshell($it, $x)
!ll&&!rl&&r
268360
$kw eq "(" and my $sub = _subshell($it, $x)
!ll&&!rl&&r
000
MC/DC0%0/2
$kw eq "(" and my $sub = _subshell($it, $x)
$kw eq "(" my $sub = _subshell($it, $x)
MC/DC0%0/2
$kw eq "(" and my $sub = _subshell($it, $x)
$kw eq "(" my $sub = _subshell($it, $x)
Truth table66%2/3
A and B
A= $kw eq "("B= my $sub = _subshell($it, $x)
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $kw eq "("B= my $sub = _subshell($it, $x)
ABresult
0X0
100
111
375 # Funktion: name() { … } bzw. function name [()] { … } — der Rumpf ist eine Gruppe
376 0 ▶ if ( $kw eq 'function' && ( my ( $fname, $frest ) = $x->{raw} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "function" and () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s) 7 2676 2683
if ($kw eq "function" and () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s) 0 0 0
Condition33%2/6
$kw eq "function" and () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
!ll&&!rl&&r
267607
$kw eq "function" and () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
!ll&&!rl&&r
000
MC/DC50%1/2
$kw eq "function" and () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
$kw eq "function" () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
MC/DC0%0/2
$kw eq "function" and () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
$kw eq "function" () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
Truth table66%2/3
A and B
A= $kw eq "function"B= () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $kw eq "function"B= () = $x->{"raw"} =~ /\A(?:function\s+)?([A-Za-z_][\w-]*)\s*(?:\(\s*\))?\s*(.*)\z/s
ABresult
0X0
100
111
377 0 ▶ if ( !length $frest ) { my $y = _next($it) or die "bash: syntax error: unexpected end of file\n"; $frest = $y->{raw} }
Branch: 4 branches
BranchTrueFalseTotal
unless (length $frest) 0 7 7
my $y = _next($it) or die "bash: syntax error: unexpected end of file\n" 0 0 0
unless (length $frest) 0 0 0
my $y = _next($it) or die "bash: syntax error: unexpected end of file\n" 0 0 0
378 0 ▶ if ( $frest =~ /\A\{(?:\s+(.*))?\z/s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($frest =~ /\A\{(?:\s+(.*))?\z/s) 7 0 7
if ($frest =~ /\A\{(?:\s+(.*))?\z/s) 0 0 0
379 0 ▶ unshift @$it, { %$x, raw => $1, op => ';' } if defined $1 && length $1;
Branch: 2 branches
BranchTrueFalseTotal
if defined $1 and length $1 3 4 7
if defined $1 and length $1 0 0 0
Condition33%2/6
defined $1 and length $1
!ll&&!rl&&r
403
defined $1 and length $1
!ll&&!rl&&r
000
MC/DC50%1/2
defined $1 and length $1
defined $1 length $1
MC/DC0%0/2
defined $1 and length $1
defined $1 length $1
Truth table66%2/3
A and B
A= defined $1B= length $1
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $1B= length $1
ABresult
0X0
100
111
380 0 my ( $body, $s ) = _parse_list( $it, { '}' => 1 } );
381 0 ▶ die "bash: syntax error: unexpected end of file\n" unless $s;
Branch: 2 branches
BranchTrueFalseTotal
unless $s 0 7 7
unless $s 0 0 0
382 0 push @nodes, { type => 'func', op => $x->{op}, name => $fname, body => $body, raw => $x->{raw} };
383 0 next;
384 }
385 0 unshift @$it, { %$x, raw => $frest, op => ';' };
386 0 push @nodes, _skip_block( $it, $x );
387 0 next;
388 }
389 0 ▶ if ( $kw eq 'function' || $kw eq '{' || $kw eq '(' || $kw eq '((' || $kw eq 'select' ) { push @nodes, _skip_block( $it, $x ); next }
Branch: 2 branches
BranchTrueFalseTotal
if ($kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "((" or $kw eq "select") 0 2676 2676
if ($kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "((" or $kw eq "select") 0 0 0
Condition16%4/24
$kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "((" or $kw eq "select"
l!l&&r!l&&!r
002676
$kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "(("
l!l&&r!l&&!r
002676
$kw eq "function" or $kw eq "{" or $kw eq "("
l!l&&r!l&&!r
002676
$kw eq "function" or $kw eq "{"
l!l&&r!l&&!r
002676
$kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "((" or $kw eq "select"
l!l&&r!l&&!r
000
$kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "(("
l!l&&r!l&&!r
000
$kw eq "function" or $kw eq "{" or $kw eq "("
l!l&&r!l&&!r
000
$kw eq "function" or $kw eq "{"
l!l&&r!l&&!r
000
MC/DC0%0/5
$kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "((" or $kw eq "select"
$kw eq "function" $kw eq "{" $kw eq "(" $kw eq "((" $kw eq "select"
MC/DC0%0/5
$kw eq "function" or $kw eq "{" or $kw eq "(" or $kw eq "((" or $kw eq "select"
$kw eq "function" $kw eq "{" $kw eq "(" $kw eq "((" $kw eq "select"
Truth table16%1/6
A or B or C or D or E
A= $kw eq "function"B= $kw eq "{"C= $kw eq "("D= $kw eq "(("E= $kw eq "select"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
Truth table0%0/6
A or B or C or D or E
A= $kw eq "function"B= $kw eq "{"C= $kw eq "("D= $kw eq "(("E= $kw eq "select"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
390 0 ▶ if ( $kw && $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/ ) { die "bash: syntax error near unexpected token `$kw'\n" }
Branch: 2 branches
BranchTrueFalseTotal
if ($kw and $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/) 0 2676 2676
if ($kw and $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/) 0 0 0
Condition16%1/6
$kw and $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
!ll&&!rl&&r
267600
$kw and $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
!ll&&!rl&&r
000
MC/DC0%0/2
$kw and $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
$kw $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
MC/DC0%0/2
$kw and $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
$kw $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
Truth table33%1/3
A and B
A= $kwB= $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $kwB= $kw =~ /\A(?:then|elif|else|fi|do|done|esac|\})\z/
ABresult
0X0
100
111
391 0 ▶ if ( $x->{raw} =~ /\A(break|continue)(?:\s+(\d+))?\s*\z/ ) { push @nodes, { type => $1, op => $x->{op}, n => $2 // 1 }; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($x->{"raw"} =~ /\A(break|continue)(?:\s+(\d+))?\s*\z/) 3 2673 2676
if ($x->{"raw"} =~ /\A(break|continue)(?:\s+(\d+))?\s*\z/) 0 0 0
Condition50%2/4
$2 // 1
l!l
12
$2 // 1
l!l
00
MC/DC100%1/1
$2 // 1
$2
MC/DC0%0/1
$2 // 1
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
Truth table0%0/2
A
A= $2
Aresult
11
00
392 0 ▶ push @nodes, { type => 'cmd', op => $x->{op}, raw => $x->{raw}, map { exists $x->{$_} ? ( $_ => $x->{$_} ) : () } qw( heredoc expand_doc herestring ) };
Branch: 2 branches
BranchTrueFalseTotal
exists $x->{$_} ? : 13 8006 8019
exists $x->{$_} ? : 0 0 0
393 }
394 0 return ( \@nodes, undef );
395 }
396  
397 # Rest hinter done/fi: Umleitung oder Pipe (done < datei, done | sort, done > aus)
398 31 ▶sub _post {
Subroutine _post: called CC=2 SCAR=10.3
399 0 ▶ my ( $item, $kw ) = @_;
Subroutine _post: not called CC=2 SCAR=10.3
400 0 ( my $r = $item->{raw} ) =~ s/\A\Q$kw\E\s*//;
401 0 ▶ return { raw => $r, map { exists $item->{$_} ? ( $_ => $item->{$_} ) : () } qw( heredoc expand_doc herestring ) };
Branch: 2 branches
BranchTrueFalseTotal
exists $item->{$_} ? : 0 93 93
exists $item->{$_} ? : 0 0 0
402 }
403  
404 5 ▶sub _split_pats {
Subroutine _split_pats: called CC=7 SCAR=31.3
405 0 ▶ my ($p) = @_;
Subroutine _split_pats: not called CC=7 SCAR=31.3
406 0 my @p;
407 0 my $cur = '';
408 0 my $q = '';
409 0 for my $c ( split //, $p ) {
410 0 ▶ if ( $q ) { $cur .= $c; $q = '' if $c eq $q; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($q) 0 23 23
if $c eq $q 0 0 0
if ($q) 0 0 0
if $c eq $q 0 0 0
411 0 ▶ if ( $c eq '"' || $c eq "'" ) { $q = $c; $cur .= $c; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\"" or $c eq "'") 0 23 23
if ($c eq "\"" or $c eq "'") 0 0 0
Condition16%1/6
$c eq "\"" or $c eq "'"
l!l&&r!l&&!r
0023
$c eq "\"" or $c eq "'"
l!l&&r!l&&!r
000
MC/DC0%0/2
$c eq "\"" or $c eq "'"
$c eq "\"" $c eq "'"
MC/DC0%0/2
$c eq "\"" or $c eq "'"
$c eq "\"" $c eq "'"
Truth table33%1/3
A or B
A= $c eq "\""B= $c eq "'"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $c eq "\""B= $c eq "'"
ABresult
1X1
011
000
412 0 ▶ if ( $c eq '|' ) { push @p, $cur; $cur = ''; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "|") 2 21 23
if ($c eq "|") 0 0 0
413 0 $cur .= $c;
414 }
415 0 push @p, $cur;
416 0 return map { s/\A\s+|\s+\z//gr } @p;
417 }
418  
419 # Subshell ( liste ): Glieder bis zur schliessenden Klammer (nicht in Anführungszeichen,
420 # $( ), verschachtelten Klammern); dahinter Pipe oder Umleitung wie bei { }. Ohne
421 # schliessende Klammer: undef (dann eine Luecke wie bisher).
422 6 ▶sub _subshell {
Subroutine _subshell: called CC=4 SCAR=18.8
423 0 ▶ my ( $it, $x ) = @_;
Subroutine _subshell: not called CC=4 SCAR=18.8
424 0 my @items = ( { %$x, raw => substr( $x->{raw}, 1 ) =~ s/\A\s+//r, op => ';' } );
425 0 my $taken = 0;
426 0 while (1) {
427 0 my $y = $items[-1];
428 0 my $at = _close_sub( $y->{raw} );
429 0 ▶ if ( defined $at ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $at) 6 7 13
if (defined $at) 0 0 0
430 0 my $post = substr( $y->{raw}, $at + 1 ) =~ s/\A\s+//r;
431 0 $y->{raw} = substr( $y->{raw}, 0, $at ) =~ s/\s+\z//r;
432 0 splice @$it, 0, $taken;
433 0 my ( $body, $s ) = _parse_list( [ grep { length $_->{raw} } @items ], {} );
434 0 ▶ die "bash: syntax error near unexpected token `$s->{word}'\n" if $s;
Branch: 2 branches
BranchTrueFalseTotal
if $s 0 6 6
if $s 0 0 0
435 0 return { type => 'group', subshell => 1, op => $x->{op}, body => $body, post => { raw => $post } };
436 }
437 0 ▶ return undef if $taken >= @$it;
Branch: 2 branches
BranchTrueFalseTotal
if $taken >= @$it 0 7 7
if $taken >= @$it 0 0 0
438 0 push @items, { %{ $it->[ $taken++ ] } };
439 }
440 }
441  
442 # Stelle der schliessenden Klammer einer Subshell in einem Glied (oder undef)
443 13 ▶sub _close_sub {
Subroutine _close_sub: called CC=11 SCAR=36.6
444 0 ▶ my ($r) = @_;
Subroutine _close_sub: not called CC=11 SCAR=36.6
445 0 my ( $depth, $i, $n ) = ( 0, 0, length $r );
446 0 ▶ while ( $i < $n ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i < $n) 109 7 116
if ($i < $n) 0 0 0
447 0 my $c = substr( $r, $i, 1 );
448 0 ▶ if ( $c eq '\\' ) { $i += 2; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\\") 0 109 109
if ($c eq "\\") 0 0 0
449 0 ▶ if ( $c eq "'" ) { my $j = index( $r, "'", $i + 1 ); return undef if $j < 0; $i = $j + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq "'") 2 107 109
if $j < 0 0 2 2
if ($c eq "'") 0 0 0
if $j < 0 0 0 0
450 0 ▶ if ( $c eq '"' || $c eq '`' ) { my $j = _close_quote( $r, $i ); return undef if $j < 0; $i = $j + 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq "\"" or $c eq "`") 2 105 107
if $j < 0 0 2 2
if ($c eq "\"" or $c eq "`") 0 0 0
if $j < 0 0 0 0
Condition33%2/6
$c eq "\"" or $c eq "`"
l!l&&r!l&&!r
20105
$c eq "\"" or $c eq "`"
l!l&&r!l&&!r
000
MC/DC50%1/2
$c eq "\"" or $c eq "`"
$c eq "\"" $c eq "`"
MC/DC0%0/2
$c eq "\"" or $c eq "`"
$c eq "\"" $c eq "`"
Truth table66%2/3
A or B
A= $c eq "\""B= $c eq "`"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $c eq "\""B= $c eq "`"
ABresult
1X1
011
000
451 0 ▶ if ( $c eq '(' ) { $depth++ }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq '(') { } 0 105 105
elsif ($c eq ')') { } 6 99 105
if ($c eq '(') { } 0 0 0
elsif ($c eq ')') { } 0 0 0
452 0 ▶ elsif ( $c eq ')' ) { return $i unless $depth; $depth-- }
Branch: 2 branches
BranchTrueFalseTotal
unless $depth 6 0 6
unless $depth 0 0 0
453 0 $i++;
454 }
455 0 return undef;
456 }
457  
458 # nicht nachgebildeter Block (Funktion, { }, ( ), for (( ))): bis zum Ende ueberspringen, Luecke
459 0 ▶sub _skip_block {
Subroutine _skip_block: not called CC=7 SCAR=40.3
460 0 ▶ my ( $it, $x ) = @_;
Subroutine _skip_block: not called CC=7 SCAR=40.3
461 0 my @raw = ( $x->{raw} );
462 0 my $open = () = $x->{raw} =~ /(?:^|[\s;])(?:\{|do|then)(?=\s|$)/g;
463 0 my $close = () = $x->{raw} =~ /(?:^|[\s;])(?:\}|done|fi)(?=\s|$)/g;
464 0 my $depth = $open - $close;
465 0 ▶ $depth = 0 if $x->{raw} =~ /\A\(/ && $x->{raw} =~ /\)\s*\z/;
Branch: 2 branches
BranchTrueFalseTotal
if $x->{"raw"} =~ /\A\(/ and $x->{"raw"} =~ /\)\s*\z/ 0 0 0
if $x->{"raw"} =~ /\A\(/ and $x->{"raw"} =~ /\)\s*\z/ 0 0 0
Condition0%0/6
$x->{"raw"} =~ /\A\(/ and $x->{"raw"} =~ /\)\s*\z/
!ll&&!rl&&r
000
$x->{"raw"} =~ /\A\(/ and $x->{"raw"} =~ /\)\s*\z/
!ll&&!rl&&r
000
MC/DC0%0/2
$x->{"raw"} =~ /\A\(/ and $x->{"raw"} =~ /\)\s*\z/
$x->{"raw"} =~ /\A\(/ $x->{"raw"} =~ /\)\s*\z/
MC/DC0%0/2
$x->{"raw"} =~ /\A\(/ and $x->{"raw"} =~ /\)\s*\z/
$x->{"raw"} =~ /\A\(/ $x->{"raw"} =~ /\)\s*\z/
Truth table0%0/3
A and B
A= $x->{"raw"} =~ /\A\(/B= $x->{"raw"} =~ /\)\s*\z/
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $x->{"raw"} =~ /\A\(/B= $x->{"raw"} =~ /\)\s*\z/
ABresult
0X0
100
111
466 0 ▶ while ( $depth > 0 && @$it ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($depth > 0 and @$it) 0 0 0
if ($depth > 0 and @$it) 0 0 0
Condition0%0/6
$depth > 0 and @$it
!ll&&!rl&&r
000
$depth > 0 and @$it
!ll&&!rl&&r
000
MC/DC0%0/2
$depth > 0 and @$it
$depth > 0 @$it
MC/DC0%0/2
$depth > 0 and @$it
$depth > 0 @$it
Truth table0%0/3
A and B
A= $depth > 0B= @$it
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $depth > 0B= @$it
ABresult
0X0
100
111
467 0 my $y = shift @$it;
468 0 push @raw, $y->{raw};
469 0 ▶ $depth++ while $y->{raw} =~ /(?:^|[\s;])(?:\{|do|then)(?=\s|$)/g;
Branch: 2 branches
BranchTrueFalseTotal
$y->{"raw"} =~ /(?:^|[\s;])(?:\{|do|then)(?=\s|$)/g and do { ++$depth } 0 0 0
$y->{"raw"} =~ /(?:^|[\s;])(?:\{|do|then)(?=\s|$)/g and do { ++$depth } 0 0 0
470 0 ▶ $depth-- while $y->{raw} =~ /(?:^|[\s;])(?:\}|done|fi)(?=\s|$)/g;
Branch: 2 branches
BranchTrueFalseTotal
$y->{"raw"} =~ /(?:^|[\s;])(?:\}|done|fi)(?=\s|$)/g and do { --$depth } 0 0 0
$y->{"raw"} =~ /(?:^|[\s;])(?:\}|done|fi)(?=\s|$)/g and do { --$depth } 0 0 0
471 }
472 0 return { type => 'gap', op => $x->{op}, raw => join( '; ', @raw ) };
473 }
474  
475 # --- Expansion ---------------------------------------------------------------------
476  
477  
478 4784 ▶sub expand {
Subroutine expand: called CC=33 SCAR=53.3
Pod documented
479 0 ▶ my ( $s, $env, $cmdsub ) = @_;
Subroutine expand: not called CC=33 SCAR=53.3
Pod documented
480 0 my $out = '';
481 0 my $q = '';
482 0 my $i = 0;
483 0 my $n = length $s;
484 0 my $word = ''; # bisheriges Wort (ohne Quotes) — fuer NAME=wert ohne Wortaufteilung
485 198 ▶ my $emit = sub {
Subroutine __ANON__: called CC=4 SCAR=18.5
486 0 ▶ my ($v) = @_;
Subroutine __ANON__: not called CC=4 SCAR=18.5
487 0 ▶ $v //= '';
Condition25%1/4
$v //= ""
l!l
1980
$v //= ""
l!l
00
MC/DC0%0/1
$v //= ""
$v
MC/DC0%0/1
$v //= ""
$v
Truth table50%1/2
A
A= $v
Aresult
11
00
Truth table0%0/2
A
A= $v
Aresult
11
00
488 0 ▶ if ( $q eq '"' ) { $out .= $v =~ s/(["\\\$`])/\\$1/gr; return }
Branch: 2 branches
BranchTrueFalseTotal
if ($q eq "\"") 87 111 198
if ($q eq "\"") 0 0 0
489 0 ▶ if ( $word =~ /\A[A-Za-z_]\w*\+?=/ ) { $out .= "'" . ( $v =~ s/'/'\\''/gr ) . "'"; return } # Zuweisung: ein Wort
Branch: 2 branches
BranchTrueFalseTotal
if ($word =~ /\A[A-Za-z_]\w*\+?=/) 32 79 111
if ($word =~ /\A[A-Za-z_]\w*\+?=/) 0 0 0
490 0 my @w = split ' ', $v;
491 0 $out .= join ' ', map { "'" . s/'/'\\''/gr . "'" } @w;
492 0 };
493 0 ▶ while ( $i < $n ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i < $n) 82515 4782 87297
if ($i < $n) 0 0 0
494 0 my $c = substr( $s, $i, 1 );
495 0 ▶ if ( $q eq '' && $c eq "'" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($q eq "" and $c eq "'") 343 82172 82515
if ($q eq "" and $c eq "'") 0 0 0
Condition50%3/6
$q eq "" and $c eq "'"
!ll&&!rl&&r
721074962343
$q eq "" and $c eq "'"
!ll&&!rl&&r
000
MC/DC100%2/2
$q eq "" and $c eq "'"
$q eq "" $c eq "'"
MC/DC0%0/2
$q eq "" and $c eq "'"
$q eq "" $c eq "'"
Truth table100%3/3
A and B
A= $q eq ""B= $c eq "'"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $q eq ""B= $c eq "'"
ABresult
0X0
100
111
496 0 my $j = index( $s, "'", $i + 1 );
497 0 ▶ $j = $n - 1 if $j < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j < 0 0 343 343
if $j < 0 0 0 0
498 0 $out .= substr( $s, $i, $j - $i + 1 );
499 0 $word .= 'x';
500 0 $i = $j + 1;
501 0 next;
502 }
503 0 ▶ if ( $c eq '"' ) { $q = $q eq '"' ? '' : '"'; $out .= $c; $i++; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq "\"") 562 81610 82172
$q eq '"' ? : 281 281 562
if ($c eq "\"") 0 0 0
$q eq '"' ? : 0 0 0
504 0 ▶ if ( $c eq '\\' ) { $out .= substr( $s, $i, 2 ); $word .= substr( $s, $i + 1, 1 ); $i += 2; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\\") 22 81588 81610
if ($c eq "\\") 0 0 0
505 0 ▶ if ( $q eq '' && $c =~ /\s/ ) { $out .= $c; $word = ''; $i++; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($q eq "" and $c =~ /\s/) 7880 73708 81588
if ($q eq "" and $c =~ /\s/) 0 0 0
Condition50%3/6
$q eq "" and $c =~ /\s/
!ll&&!rl&&r
6924667847880
$q eq "" and $c =~ /\s/
!ll&&!rl&&r
000
MC/DC100%2/2
$q eq "" and $c =~ /\s/
$q eq "" $c =~ /\s/
MC/DC0%0/2
$q eq "" and $c =~ /\s/
$q eq "" $c =~ /\s/
Truth table100%3/3
A and B
A= $q eq ""B= $c =~ /\s/
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $q eq ""B= $c =~ /\s/
ABresult
0X0
100
111
506 0 ▶ if ( $c eq '`' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "`") 1 73707 73708
if ($c eq "`") 0 0 0
507 0 my $j = _close_quote( $s, $i );
508 0 ▶ $j = $n - 1 if $j < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j < 0 0 1 1
if $j < 0 0 0 0
509 0 my $inner = substr( $s, $i + 1, $j - $i - 1 );
510 0 $emit->( _strip_nl( $cmdsub->($inner) ) );
511 0 $i = $j + 1;
512 0 next;
513 }
514 0 ▶ if ( $c eq '$' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq "\$") 201 73506 73707
if ($c eq "\$") 0 0 0
515 0 my $nx = substr( $s, $i + 1, 1 );
516 0 ▶ if ( $q eq '' && $nx eq "'" ) { # $'…' mit Escapes
Branch: 2 branches
BranchTrueFalseTotal
if ($q eq "" and $nx eq "'") 1 200 201
if ($q eq "" and $nx eq "'") 0 0 0
Condition50%3/6
$q eq "" and $nx eq "'"
!ll&&!rl&&r
881121
$q eq "" and $nx eq "'"
!ll&&!rl&&r
000
MC/DC100%2/2
$q eq "" and $nx eq "'"
$q eq "" $nx eq "'"
MC/DC0%0/2
$q eq "" and $nx eq "'"
$q eq "" $nx eq "'"
Truth table100%3/3
A and B
A= $q eq ""B= $nx eq "'"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $q eq ""B= $nx eq "'"
ABresult
0X0
100
111
517 0 my $j = $i + 2;
518 0 my $v = '';
519 0 ▶ while ( $j < $n && substr( $s, $j, 1 ) ne "'" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j < $n and substr($s, $j, 1) ne "'") 3 1 4
if ($j < $n and substr($s, $j, 1) ne "'") 0 0 0
Condition33%2/6
$j < $n and substr($s, $j, 1) ne "'"
!ll&&!rl&&r
013
$j < $n and substr($s, $j, 1) ne "'"
!ll&&!rl&&r
000
MC/DC50%1/2
$j < $n and substr($s, $j, 1) ne "'"
$j < $n substr($s, $j, 1) ne "'"
MC/DC0%0/2
$j < $n and substr($s, $j, 1) ne "'"
$j < $n substr($s, $j, 1) ne "'"
Truth table66%2/3
A and B
A= $j < $nB= substr($s, $j, 1) ne "'"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $j < $nB= substr($s, $j, 1) ne "'"
ABresult
0X0
100
111
520 0 my $x = substr( $s, $j, 1 );
521 0 ▶ if ( $x eq '\\' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($x eq "\\") 1 2 3
if ($x eq "\\") 0 0 0
522 0 my $e = substr( $s, $j + 1, 1 );
523 0 ▶ $v .= { n => "\n", t => "\t", r => "\r", '\\' => '\\', "'" => "'", '"' => '"', a => "\a", e => "\e", 0 => "\0" }->{$e} // "\\$e";
Condition25%1/4
{"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e} // "\\$e"
l!l
10
{"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e} // "\\$e"
l!l
00
MC/DC0%0/1
{"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e} // "\\$e"
{"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e}
MC/DC0%0/1
{"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e} // "\\$e"
{"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e}
Truth table50%1/2
A
A= {"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e}
Aresult
11
00
Truth table0%0/2
A
A= {"n", "\n", "t", "\t", "r", "\r", "\\", "\\", "'", "'", "\"", "\"", "a", "\a", "e", "\e", 0, "\0"}->{$e}
Aresult
11
00
524 0 $j += 2;
525 0 next;
526 }
527 0 $v .= $x;
528 0 $j++;
529 }
530 0 $out .= "'" . ( $v =~ s/'/'\\''/gr ) . "'";
531 0 $word .= 'x';
532 0 $i = $j + 1;
533 0 next;
534 }
535 0 ▶ if ( substr( $s, $i, 3 ) eq '$((' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($s, $i, 3) eq "\$((") 21 179 200
if (substr($s, $i, 3) eq "\$((") 0 0 0
536 0 my $j = _close_paren( $s, $i + 1 );
537 0 ▶ if ( $j > 0 && substr( $s, $j - 1, 1 ) eq ')' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($j > 0 and substr($s, $j - 1, 1) eq ")") 21 0 21
if ($j > 0 and substr($s, $j - 1, 1) eq ")") 0 0 0
Condition16%1/6
$j > 0 and substr($s, $j - 1, 1) eq ")"
!ll&&!rl&&r
0021
$j > 0 and substr($s, $j - 1, 1) eq ")"
!ll&&!rl&&r
000
MC/DC0%0/2
$j > 0 and substr($s, $j - 1, 1) eq ")"
$j > 0 substr($s, $j - 1, 1) eq ")"
MC/DC0%0/2
$j > 0 and substr($s, $j - 1, 1) eq ")"
$j > 0 substr($s, $j - 1, 1) eq ")"
Truth table33%1/3
A and B
A= $j > 0B= substr($s, $j - 1, 1) eq ")"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $j > 0B= substr($s, $j - 1, 1) eq ")"
ABresult
0X0
100
111
538 0 my $expr = substr( $s, $i + 3, $j - $i - 4 );
539 0 $emit->( arith( $expr, $env, $cmdsub ) );
540 0 $i = $j + 1;
541 0 next;
542 }
543 }
544 0 ▶ if ( $nx eq '(' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nx eq "(") 8 171 179
if ($nx eq "(") 0 0 0
545 0 my $j = _close_paren( $s, $i + 1 );
546 0 ▶ $j = $n - 1 if $j < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j < 0 0 8 8
if $j < 0 0 0 0
547 0 $emit->( _strip_nl( $cmdsub->( substr( $s, $i + 2, $j - $i - 2 ) ) ) );
548 0 $i = $j + 1;
549 0 next;
550 }
551 0 ▶ if ( $nx eq '{' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nx eq "{") 46 125 171
if ($nx eq "{") 0 0 0
552 0 my $j = _close_paren( $s, $i + 1 );
553 0 ▶ $j = $n - 1 if $j < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $j < 0 0 46 46
if $j < 0 0 0 0
554 0 $emit->( _param( substr( $s, $i + 2, $j - $i - 2 ), $env, $cmdsub ) );
555 0 $i = $j + 1;
556 0 next;
557 }
558 0 ▶ if ( substr( $s, $i + 1 ) =~ /\A([A-Za-z_]\w*|[0-9?\$#@*!-])/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($s, $i + 1) =~ /\A([A-Za-z_]\w*|[0-9?\$#@*!-])/) 125 0 125
if (substr($s, $i + 1) =~ /\A([A-Za-z_]\w*|[0-9?\$#@*!-])/) 0 0 0
559 0 my $name = $1;
560 0 ▶ if ( $name eq '@' && $q eq '"' ) { # "$@": jedes Argument ein Wort
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq '@' and $q eq '"') { } 1 124 125
if ($name eq '@' and $q eq '"') { } 0 0 0
Condition33%2/6
$name eq "\@" and $q eq "\""
!ll&&!rl&&r
12401
$name eq "\@" and $q eq "\""
!ll&&!rl&&r
000
MC/DC50%1/2
$name eq "\@" and $q eq "\""
$name eq "\@" $q eq "\""
MC/DC0%0/2
$name eq "\@" and $q eq "\""
$name eq "\@" $q eq "\""
Truth table66%2/3
A and B
A= $name eq "\@"B= $q eq "\""
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $name eq "\@"B= $q eq "\""
ABresult
0X0
100
111
561 0 ▶ $out .= join '" "', map { s/(["\\\$`])/\\$1/gr } @{ $env->{args} || [] };
Condition25%1/4
$env->{'args'} || []
l!l
10
$env->{'args'} || []
l!l
00
MC/DC0%0/1
$env->{'args'} || []
$env->{'args'}
MC/DC0%0/1
$env->{'args'} || []
$env->{'args'}
Truth table50%1/2
A
A= $env->{'args'}
Aresult
11
00
Truth table0%0/2
A
A= $env->{'args'}
Aresult
11
00
562 }
563 0 ▶ else { $emit->( $name eq '@' || $name eq '*' ? join( ' ', @{ $env->{args} || [] } ) : _var( $name, $env ) ) }
Branch: 2 branches
BranchTrueFalseTotal
$name eq '@' || $name eq '*' ? : 2 122 124
$name eq '@' || $name eq '*' ? : 0 0 0
Condition30%3/10
$name eq "\@" or $name eq "*"
l!l&&r!l&&!r
02122
$env->{'args'} || []
l!l
20
$name eq "\@" or $name eq "*"
l!l&&r!l&&!r
000
$env->{'args'} || []
l!l
00
MC/DC50%1/2
$name eq "\@" or $name eq "*"
$name eq "\@" $name eq "*"
MC/DC0%0/1
$env->{'args'} || []
$env->{'args'}
MC/DC0%0/2
$name eq "\@" or $name eq "*"
$name eq "\@" $name eq "*"
MC/DC0%0/1
$env->{'args'} || []
$env->{'args'}
Truth table66%2/3
A or B
A= $name eq "\@"B= $name eq "*"
ABresult
1X1
011
000
Truth table50%1/2
A
A= $env->{'args'}
Aresult
11
00
Truth table0%0/3
A or B
A= $name eq "\@"B= $name eq "*"
ABresult
1X1
011
000
Truth table0%0/2
A
A= $env->{'args'}
Aresult
11
00
564 0 $i += 1 + length $name;
565 0 next;
566 }
567 }
568 0 $out .= $c;
569 0 $word .= $c;
570 0 $i++;
571 }
572 0 return $out;
573 }
574  
575 9 ▶sub _strip_nl { my ($v) = @_; $v //= ''; $v =~ s/\n+\z//; return $v }
Subroutine _strip_nl: called CC=2 SCAR=7.0
Condition50%1/2
$v //= ""
l!l
90
MC/DC0%0/1
$v //= ""
$v
Truth table50%1/2
A
A= $v
Aresult
11
00
576  
577 183 ▶sub _var {
Subroutine _var: called CC=18 SCAR=30.4
578 183 my ( $name, $env ) = @_;
579 183 ▶ return $env->{rc} // 0 if $name eq '?';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "?" 22 161 183
Condition50%1/2
$env->{"rc"} // 0
l!l
220
MC/DC0%0/1
$env->{"rc"} // 0
$env->{"rc"}
Truth table50%1/2
A
A= $env->{"rc"}
Aresult
11
00
580 161 ▶ return 4242 if $name eq '$';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "\$" 0 161 161
581 161 ▶ return scalar @{ $env->{args} || [] } if $name eq '#';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "#" 1 160 161
Condition50%1/2
$env->{'args'} || []
l!l
10
MC/DC0%0/1
$env->{'args'} || []
$env->{'args'}
Truth table50%1/2
A
A= $env->{'args'}
Aresult
11
00
582 160 ▶ return $env->{args}[ $name - 1 ] // '' if $name =~ /\A[1-9]\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A[1-9]\z/ 9 151 160
Condition100%2/2
$env->{"args"}[$name - 1] // ""
l!l
72
MC/DC100%1/1
$env->{"args"}[$name - 1] // ""
$env->{"args"}[$name - 1]
Truth table100%2/2
A
A= $env->{"args"}[$name - 1]
Aresult
11
00
583 151 ▶ return $env->{arg0} // 'bash' if $name eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq 0 1 150 151
Condition50%1/2
$env->{"arg0"} // "bash"
l!l
10
MC/DC0%0/1
$env->{"arg0"} // "bash"
$env->{"arg0"}
Truth table50%1/2
A
A= $env->{"arg0"}
Aresult
11
00
584 150 ▶ return '' if $name eq '!' || $name eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "!" or $name eq "-" 0 150 150
Condition33%1/3
$name eq "!" or $name eq "-"
l!l&&r!l&&!r
00150
MC/DC0%0/2
$name eq "!" or $name eq "-"
$name eq "!" $name eq "-"
Truth table33%1/3
A or B
A= $name eq "!"B= $name eq "-"
ABresult
1X1
011
000
585 150 ▶ return ( $env->{pipestatus} || [ $env->{rc} // 0 ] )->[0] if $name eq 'PIPESTATUS';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "PIPESTATUS" 1 149 150
Condition25%1/4
$env->{'pipestatus'} || [$env->{'rc'} // 0]
l!l
10
$env->{"rc"} // 0
l!l
00
MC/DC0%0/1
$env->{'pipestatus'} || [$env->{'rc'} // 0]
$env->{'pipestatus'}
MC/DC0%0/1
$env->{"rc"} // 0
$env->{"rc"}
Truth table50%1/2
A
A= $env->{'pipestatus'}
Aresult
11
00
Truth table0%0/2
A
A= $env->{"rc"}
Aresult
11
00
586 149 ▶ return $env->{vars}{$name} if exists $env->{vars}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $env->{"vars"}{$name} 145 4 149
587 4 ▶ return $env->{defaults}{$name} if $env->{defaults} && exists $env->{defaults}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $env->{"defaults"} and exists $env->{"defaults"}{$name} 1 3 4
Condition100%3/3
$env->{"defaults"} and exists $env->{"defaults"}{$name}
!ll&&!rl&&r
211
MC/DC100%2/2
$env->{"defaults"} and exists $env->{"defaults"}{$name}
$env->{"defaults"} exists $env->{"defaults"}{$name}
Truth table100%3/3
A and B
A= $env->{"defaults"}B= exists $env->{"defaults"}{$name}
ABresult
0X0
100
111
588 3 return '';
589 }
590  
591 1 ▶sub _isset {
Subroutine _isset: called CC=5 SCAR=19.4
592 1 my ( $name, $env ) = @_;
593 1 ▶ return 1 if $name =~ /\A[?\$#0]\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A[?\$#0]\z/ 0 1 1
594 1 ▶ return defined $env->{args}[ $name - 1 ] if $name =~ /\A[1-9]\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A[1-9]\z/ 0 1 1
595 1 ▶ return exists $env->{vars}{$name} || $env->{defaults} && exists $env->{defaults}{$name};
Condition33%2/6
exists $env->{'vars'}{$name} || $env->{'defaults'} && exists $env->{'defaults'}{$name}
l!l&&r!l&&!r
001
$env->{"defaults"} and exists $env->{"defaults"}{$name}
!ll&&!rl&&r
100
MC/DC0%0/3
exists $env->{'vars'}{$name} || $env->{'defaults'} && exists $env->{'defaults'}{$name}
exists $env->{'vars'}{$name} $env->{"defaults"} exists $env->{"defaults"}{$name}
Truth table25%1/4
A || B and C
A= exists $env->{'vars'}{$name}B= $env->{"defaults"}C= exists $env->{"defaults"}{$name}
ABCresult
1XX1
0111
00X0
0100
596 }
597  
598 # ${…}
599 46 ▶sub _param {
Subroutine _param: called CC=52 SCAR=53.0
600 46 my ( $p, $env, $cmdsub ) = @_;
601 46 ▶ my $word = sub { my ($w) = @_; my $x = expand( $w, $env, $cmdsub ); my @w = eval { shell_words($x) }; join ' ', grep { !ref } @w };
Subroutine __ANON__: called CC=1 SCAR=0.0
602 46 ▶ if ( $p =~ /\A(#?)PIPESTATUS(?:\[(\d+|[@*])\])?\z/ ) { # Status der Stufen der letzten Pipeline
Branch: 1 branch
BranchTrueFalseTotal
if ($p =~ /\A(#?)PIPESTATUS(?:\[(\d+|[@*])\])?\z/) 5 41 46
603 5 my ( $len, $ix ) = ( $1, $2 );
604 5 ▶ my $ps = $env->{pipestatus} || [ $env->{rc} // 0 ];
Condition25%1/4
$env->{'pipestatus'} || [$env->{'rc'} // 0]
l!l
50
$env->{"rc"} // 0
l!l
00
MC/DC0%0/1
$env->{'pipestatus'} || [$env->{'rc'} // 0]
$env->{'pipestatus'}
MC/DC0%0/1
$env->{"rc"} // 0
$env->{"rc"}
Truth table50%1/2
A
A= $env->{'pipestatus'}
Aresult
11
00
Truth table0%0/2
A
A= $env->{"rc"}
Aresult
11
00
605 5 ▶ my $all = defined $ix && ( $ix eq '@' || $ix eq '*' );
Condition66%4/6
defined $ix && ($ix eq '@' || $ix eq '*')
!ll&&!rl&&r
032
$ix eq "\@" or $ix eq "*"
l!l&&r!l&&!r
203
MC/DC33%1/3
defined $ix && ($ix eq '@' || $ix eq '*')
defined $ix $ix eq "\@" $ix eq "*"
Truth table50%2/4
A && B or C
A= defined $ixB= $ix eq "\@"C= $ix eq "*"
ABCresult
0XX0
1000
11X1
1011
606 5 ▶ return $all ? scalar @$ps : length( $ps->[ $ix // 0 ] // '' ) if $len;
Branch: 2 branches
BranchTrueFalseTotal
if $len 1 4 5
$all ? : 1 0 1
Condition0%0/4
$$ps[$ix // 0] // ""
l!l
00
$ix // 0
l!l
00
MC/DC0%0/1
$$ps[$ix // 0] // ""
$$ps[$ix // 0]
MC/DC0%0/1
$ix // 0
$ix
Truth table0%0/2
A
A= $$ps[$ix // 0]
Aresult
11
00
Truth table0%0/2
A
A= $ix
Aresult
11
00
607 4 ▶ return $all ? join( ' ', @$ps ) : $ps->[ $ix // 0 ] // '';
Branch: 1 branch
BranchTrueFalseTotal
$all ? : 1 3 4
Condition50%2/4
$$ps[$ix // 0] // ""
l!l
30
$ix // 0
l!l
30
MC/DC0%0/1
$$ps[$ix // 0] // ""
$$ps[$ix // 0]
MC/DC0%0/1
$ix // 0
$ix
Truth table50%1/2
A
A= $$ps[$ix // 0]
Aresult
11
00
Truth table50%1/2
A
A= $ix
Aresult
11
00
608 }
609 41 ▶ return length _var( $1, $env ) if $p =~ /\A#([A-Za-z_]\w*|[0-9?#])\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $p =~ /\A#([A-Za-z_]\w*|[0-9?#])\z/ 1 40 41
610 40 ▶ my ( $name, $rest ) = $p =~ /\A([A-Za-z_]\w*|[0-9?\$#@*])(.*)\z/s or die "gap: \${$p}\n";
Branch: 1 branch
BranchTrueFalseTotal
() = $p =~ /\A([A-Za-z_]\w*|[0-9?\$#@*])(.*)\z/s or die "gap: \${$p}\n" 40 0 40
611 0 ▶ my $v = $name eq '@' || $name eq '*' ? join( ' ', @{ $env->{args} || [] } ) : _var( $name, $env );
Branch: 1 branch
BranchTrueFalseTotal
$name eq '@' || $name eq '*' ? : 0 40 40
Condition20%1/5
$name eq "\@" or $name eq "*"
l!l&&r!l&&!r
0040
$env->{'args'} || []
l!l
00
MC/DC0%0/2
$name eq "\@" or $name eq "*"
$name eq "\@" $name eq "*"
MC/DC0%0/1
$env->{'args'} || []
$env->{'args'}
Truth table33%1/3
A or B
A= $name eq "\@"B= $name eq "*"
ABresult
1X1
011
000
Truth table0%0/2
A
A= $env->{'args'}
Aresult
11
00
612 40 ▶ return $v if $rest eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq "" 7 33 40
613 33 ▶ if ( $rest =~ /\A(:?)([-=+?])(.*)\z/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest =~ /\A(:?)([-=+?])(.*)\z/s) 3 30 33
614 3 my ( $colon, $o, $w ) = ( $1, $2, $3 );
615 3 ▶ my $unset = $colon ? !length $v : !_isset( $name, $env );
Branch: 1 branch
BranchTrueFalseTotal
$colon ? : 2 1 3
616 3 ▶ if ( $o eq '-' ) { return $unset ? $word->($w) : $v }
Branch: 2 branches
BranchTrueFalseTotal
if ($o eq "-") 3 0 3
$unset ? : 3 0 3
617 0 ▶ if ( $o eq '=' ) { return $v unless $unset; my $x = $word->($w); $env->{vars}{$name} = $x; return $x }
Branch: 2 branches
BranchTrueFalseTotal
if ($o eq "=") 0 0 0
unless $unset 0 0 0
618 0 ▶ if ( $o eq '+' ) { return $unset ? '' : $word->($w) }
Branch: 2 branches
BranchTrueFalseTotal
if ($o eq "+") 0 0 0
$unset ? : 0 0 0
619 0 ▶ die "bash: $name: " . ( length $w ? $word->($w) : 'parameter null or not set' ) . "\n" if $unset;
Branch: 2 branches
BranchTrueFalseTotal
if $unset 0 0 0
length $w ? : 0 0 0
620 0 return $v;
621 }
622 30 ▶ if ( $rest =~ /\A(##?|%%?)(.*)\z/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest =~ /\A(##?|%%?)(.*)\z/s) 18 12 30
623 18 my ( $o, $pat ) = ( $1, $word->($2) );
624 18 my $re = glob_re($pat);
625 18 my @cut;
626 18 ▶ if ( $o =~ /#/ ) { @cut = grep { substr( $v, 0, $_ ) =~ /\A$re\z/s } 0 .. length $v }
Branch: 1 branch
BranchTrueFalseTotal
if ($o =~ /#/) { } 9 9 18
627 9 else { @cut = grep { substr( $v, $_ ) =~ /\A$re\z/s } 0 .. length $v }
628 18 ▶ return $v unless @cut;
Branch: 1 branch
BranchTrueFalseTotal
unless @cut 0 18 18
629 18 ▶ return substr( $v, $cut[0] ) if $o eq '#';
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "#" 8 10 18
630 10 ▶ return substr( $v, $cut[-1] ) if $o eq '##';
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "##" 1 9 10
631 9 ▶ return substr( $v, 0, $cut[-1] ) if $o eq '%';
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "%" 8 1 9
632 1 return substr( $v, 0, $cut[0] );
633 }
634 12 ▶ if ( $rest =~ /\A:(?![-=+?])(.*)\z/s ) { # ${v:o} ${v:o:l}, o/l auch $(( )), $n, Ausdruck
Branch: 1 branch
BranchTrueFalseTotal
if ($rest =~ /\A:(?![-=+?])(.*)\z/s) 11 1 12
635 11 my @ol = _split_colon($1);
636 11 ▶ die "gap: \${$p}\n" if @ol > 2;
Branch: 1 branch
BranchTrueFalseTotal
if @ol > 2 0 11 11
637 11 ▶ my ( $o, $l ) = map { defined $_ ? arith( $_, $env, $cmdsub ) : undef } @ol;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 21 0 21
638 11 ▶ $o = length($v) + $o if $o < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $o < 0 1 10 11
639 11 ▶ $o = 0 if $o < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $o < 0 0 11 11
640 11 ▶ return '' if $o > length $v;
Branch: 1 branch
BranchTrueFalseTotal
if $o > length $v 0 11 11
641 11 ▶ return substr( $v, $o ) unless defined $l;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $l 1 10 11
642 10 ▶ return $l < 0 ? substr( $v, $o, length($v) - $o + $l ) : substr( $v, $o, $l );
Branch: 1 branch
BranchTrueFalseTotal
$l < 0 ? : 0 10 10
643 }
644 1 ▶ if ( $rest =~ m{\A(//?|/#|/%)((?:[^/\\]|\\.)*)(?:/(.*))?\z}s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest =~ m(\A(//?|/#|/%)((?:[^/\\]|\\.)*)(?:/(.*))?\z)s) 1 0 1
645 1 ▶ my ( $o, $pat, $r ) = ( $1, $word->($2), defined $3 ? $word->($3) : '' );
Branch: 1 branch
BranchTrueFalseTotal
defined $3 ? : 1 0 1
646 1 my $re = glob_re( $pat, 1 );
647 1 ▶ return $v =~ s/$re/$r/gr if $o eq '//';
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "//" 0 1 1
648 1 ▶ return $v =~ s/\A$re/$r/r if $o eq '/#';
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "/#" 0 1 1
649 1 ▶ return $v =~ s/$re\z/$r/r if $o eq '/%';
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "/%" 0 1 1
650 1 return $v =~ s/$re/$r/r;
651 }
652 0 ▶ return uc $v if $rest eq '^^';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq "^^" 0 0 0
653 0 ▶ return lc $v if $rest eq ',,';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq ",," 0 0 0
654 0 ▶ return ucfirst $v if $rest eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq "^" 0 0 0
655 0 ▶ return lcfirst $v if $rest eq ',';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq "," 0 0 0
656 0 die "gap: \${$p}\n";
657 }
658  
659 # "o:l" an Doppelpunkten oberster Ebene teilen (nicht in $(( )) bzw. ( ))
660 11 ▶sub _split_colon {
Subroutine _split_colon: called CC=6 SCAR=17.9
661 11 my ($s) = @_;
662 11 my ( @p, $cur, $d ) = ();
663 11 ( $cur, $d ) = ( '', 0 );
664 11 for my $c ( split //, $s ) {
665 51 ▶ $d++ if $c eq '(';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "(" 4 47 51
666 51 ▶ $d-- if $c eq ')';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq ")" 4 47 51
667 51 ▶ if ( $c eq ':' && !$d ) { push @p, $cur; $cur = ''; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq ":" and not $d) 10 41 51
Condition66%2/3
$c eq ":" and not $d
!ll&&!rl&&r
41010
MC/DC50%1/2
$c eq ":" and not $d
$c eq ":" not $d
Truth table66%2/3
A and not(B)
A= $c eq ":"B= not $d
ABresult
0X0
100
111
668 41 $cur .= $c;
669 }
670 11 push @p, $cur;
671 11 return @p;
672 }
673  
674  
675 28 ▶sub glob_re {
Subroutine glob_re: called CC=8 SCAR=24.8
Pod documented
676 28 my ( $g, $greedy ) = @_;
677 28 my $re = '';
678 28 my $i = 0;
679 28 ▶ while ( $i < length $g ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $g) 158 28 186
680 158 my $c = substr( $g, $i, 1 );
681 158 ▶ if ( $c eq '*' ) { $re .= $greedy ? '.*' : '.*?' }
Branch: 5 branches
BranchTrueFalseTotal
if ($c eq '*') { } 11 147 158
elsif ($c eq '?') { } 0 147 147
elsif ($c eq '\\') { } 0 147 147
elsif ($c eq '[' and (my $j = index($g, ']', $i + 2)) > 0) { } 0 147 147
$greedy ? : 9 2 11
682 0 elsif ( $c eq '?' ) { $re .= '.' }
683 0 elsif ( $c eq '\\' ) { $re .= quotemeta substr( $g, $i + 1, 1 ); $i++ }
684 ▶ elsif ( $c eq '[' && ( my $j = index( $g, ']', $i + 2 ) ) > 0 ) {
Condition33%1/3
$c eq "[" and (my $j = index($g, "]", $i + 2)) > 0
!ll&&!rl&&r
14700
MC/DC0%0/2
$c eq "[" and (my $j = index($g, "]", $i + 2)) > 0
$c eq "[" (my $j = index($g, "]", $i + 2)) > 0
Truth table33%1/3
A and B
A= $c eq "["B= (my $j = index($g, "]", $i + 2)) > 0
ABresult
0X0
100
111
685 0 my $set = substr( $g, $i + 1, $j - $i - 1 );
686 0 $set =~ s/\A!/^/;
687 0 $set =~ s/\\/\\\\/g;
688 0 $re .= "[$set]";
689 0 $i = $j;
690 }
691 147 else { $re .= quotemeta $c }
692 158 $i++;
693 }
694 28 return qr/$re/s;
695 }
696  
697  
698 42 ▶sub arith {
Subroutine arith: called CC=8 SCAR=25.4
Pod documented
699 42 my ( $e, $env, $cmdsub ) = @_;
700 42 ▶ $e = expand( $e, $env, $cmdsub ) if $e =~ /\$/;
Branch: 1 branch
BranchTrueFalseTotal
if $e =~ /\$/ 3 39 42
701 42 $e =~ s/'//g;
702 42 my @t = $e =~ /\G\s*(\d+|[A-Za-z_]\w*|\*\*|<=|>=|==|!=|&&|\|\||<<|>>|\+\+|--|\+=|-=|\*=|\/=|[-+*\/%()<>!=?:&|^~,])/gc;
703 42 ▶ die "gap: \$(( $e ))\n" if ( pos($e) // 0 ) < length( $e =~ s/\s+\z//r ) || grep { /\A(?:\+\+|--|[+\-*\/]?=|\?|:|,)\z/ && $_ ne '==' } @t;
Branch: 1 branch
BranchTrueFalseTotal
if (pos $e // 0) < length $e =~ s/\s+\z//r or grep {m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] and $_ ne "==";} @t 1 41 42
Condition62%5/8
(pos $e // 0) < length $e =~ s/\s+\z//r or grep {m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] and $_ ne "==";} @t
l!l&&r!l&&!r
0141
pos $e // 0
l!l
420
m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] && $_ ne '=='
!ll&&!rl&&r
9101
MC/DC0%0/2
(pos $e // 0) < length $e =~ s/\s+\z//r or grep {m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] and $_ ne "==";} @t
pos $e grep {m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] and $_ ne "==";} @t
MC/DC50%1/2
m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] && $_ ne '=='
m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] $_ ne '=='
Truth table0%0/3
A or B
A= pos $eB= grep {m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z] and $_ ne "==";} @t
ABresult
1X1
011
000
Truth table66%2/3
A && B
A= m[\A(?:\+\+|--|[+\-*/]?=|\?|:|,)\z]B= $_ ne '=='
ABresult
0X0
100
111
704 41 my $k = 0;
705 41 my ( $or, $un );
706 41 ▶ my $val = sub { my $x = $_[0]; $x =~ /\A\d+\z/ ? 0 + $x : do { my $v = _var( $x, $env ); $v =~ /\A\s*-?\d+\s*\z/ ? 0 + $v : $v eq '' ? 0 : die "gap: \$(( $e ))\n" } };
Subroutine __ANON__: called CC=4 SCAR=14.6
Branch: 3 branches
BranchTrueFalseTotal
$x =~ /\A\d+\z/ ? : 44 20 64
$v =~ /\A\s*-?\d+\s*\z/ ? : 20 0 20
$v eq '' ? : 0 0 0
707 41 my $bin;
708 41 my %prec = ( '||' => 1, '&&' => 2, '|' => 3, '^' => 4, '&' => 5, '==' => 6, '!=' => 6, '<' => 7, '>' => 7, '<=' => 7, '>=' => 7,
709 '<<' => 8, '>>' => 8, '+' => 9, '-' => 9, '*' => 10, '/' => 10, '%' => 10, '**' => 11 );
710 66 ▶ $un = sub {
Subroutine __ANON__: called CC=10 SCAR=25.1
711 66 ▶ my $x = $t[ $k++ ] // die "bash: syntax error in expression\n";
Condition50%1/2
$t[$k++] // die("bash: syntax error in expression\n")
l!l
660
MC/DC0%0/1
$t[$k++] // die("bash: syntax error in expression\n")
$t[$k++]
Truth table50%1/2
A
A= $t[$k++]
Aresult
11
00
712 66 ▶ return -$un->() if $x eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "-" 1 65 66
713 65 ▶ return +$un->() if $x eq '+';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "+" 0 65 65
714 65 ▶ return ( $un->() ? 0 : 1 ) if $x eq '!';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "!" 0 65 65
&$un() ? : 0 0 0
715 65 ▶ return ~$un->() if $x eq '~';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "~" 0 65 65
716 65 ▶ if ( $x eq '(' ) { my $v = $bin->(0); ( $t[ $k++ ] // '' ) eq ')' or die "bash: syntax error in expression\n"; return $v }
Branch: 2 branches
BranchTrueFalseTotal
if ($x eq "(") 1 64 65
($t[$k++] // "") eq ")" or die "bash: syntax error in expression\n" 1 0 1
Condition50%1/2
$t[$k++] // ""
l!l
10
MC/DC0%0/1
$t[$k++] // ""
$t[$k++]
Truth table50%1/2
A
A= $t[$k++]
Aresult
11
00
717 64 return $val->($x);
718 41 };
719 65 ▶ $bin = sub {
Subroutine __ANON__: called CC=36 SCAR=56.3
720 65 my ($min) = @_;
721 65 my $l = $un->();
722 65 ▶ while ( $k < @t && exists $prec{ $t[$k] } && $prec{ $t[$k] } > $min ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k < @t and exists $prec{$t[$k]} and $prec{$t[$k]} > $min) 23 64 87
Condition100%6/6
$k < @t and exists $prec{$t[$k]} and $prec{$t[$k]} > $min
!ll&&!rl&&r
62223
$k < @t and exists $prec{$t[$k]}
!ll&&!rl&&r
60225
MC/DC100%3/3
$k < @t and exists $prec{$t[$k]} and $prec{$t[$k]} > $min
$k < @t exists $prec{$t[$k]} $prec{$t[$k]} > $min
Truth table100%4/4
A and B and C
A= $k < @tB= exists $prec{$t[$k]}C= $prec{$t[$k]} > $min
ABCresult
0XX0
10X0
1100
1111
723 23 my $o = $t[ $k++ ];
724 23 ▶ my $r = $bin->( $o eq '**' ? $prec{$o} - 1 : $prec{$o} );
Branch: 1 branch
BranchTrueFalseTotal
$o eq '**' ? : 0 23 23
725 23 ▶ die "bash: division by 0 (error token is \"$r\")\n" if ( $o eq '/' || $o eq '%' ) && $r == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "/" || $o eq "%" and $r == 0 1 22 23
Condition100%6/6
$o eq "/" || $o eq "%" and $r == 0
!ll&&!rl&&r
2111
$o eq "/" or $o eq "%"
l!l&&r!l&&!r
1121
MC/DC33%1/3
$o eq "/" || $o eq "%" and $r == 0
$o eq "/" $o eq "%" $r == 0
Truth table60%3/5
A or B and C
A= $o eq "/"B= $o eq "%"C= $r == 0
ABCresult
00X0
1X00
0100
1X11
0111
726 84 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
727 $l = $o eq '+' ? $l + $r : $o eq '-' ? $l - $r : $o eq '*' ? $l * $r : $o eq '/' ? $l / $r : $o eq '%' ? $l % $r
728 0 ▶ : $o eq '**' ? do { no integer; int( $l**$r ) } : $o eq '<' ? ( $l < $r ? 1 : 0 ) : $o eq '>' ? ( $l > $r ? 1 : 0 )
Subroutine BEGIN: called CC=1 SCAR=4.3
Branch: 26 branches
BranchTrueFalseTotal
$o eq '+' ? : 18 4 22
$o eq '-' ? : 2 2 4
$o eq '*' ? : 1 1 2
$o eq '/' ? : 0 1 1
$o eq '%' ? : 1 0 1
$o eq '**' ? : 0 0 0
$o eq '<' ? : 0 0 0
$l < $r ? : 0 0 0
$o eq '>' ? : 0 0 0
$l > $r ? : 0 0 0
$o eq '<=' ? : 0 0 0
$l <= $r ? : 0 0 0
$o eq '>=' ? : 0 0 0
$l >= $r ? : 0 0 0
$o eq '==' ? : 0 0 0
$l == $r ? : 0 0 0
$o eq '!=' ? : 0 0 0
$l != $r ? : 0 0 0
$o eq '&&' ? : 0 0 0
$l && $r ? : 0 0 0
$o eq '||' ? : 0 0 0
$l || $r ? : 0 0 0
$o eq '&' ? : 0 0 0
$o eq '|' ? : 0 0 0
$o eq '^' ? : 0 0 0
$o eq '<<' ? : 0 0 0
Condition0%0/6
$l and $r
!ll&&!rl&&r
000
$l or $r
l!l&&r!l&&!r
000
MC/DC0%0/2
$l and $r
$l $r
MC/DC0%0/2
$l or $r
$l $r
Truth table0%0/3
A and B
A= $lB= $r
ABresult
0X0
100
111
Truth table0%0/3
A or B
A= $lB= $r
ABresult
1X1
011
000
729 : $o eq '<=' ? ( $l <= $r ? 1 : 0 ) : $o eq '>=' ? ( $l >= $r ? 1 : 0 ) : $o eq '==' ? ( $l == $r ? 1 : 0 )
730 : $o eq '!=' ? ( $l != $r ? 1 : 0 ) : $o eq '&&' ? ( $l && $r ? 1 : 0 ) : $o eq '||' ? ( $l || $r ? 1 : 0 )
731 : $o eq '&' ? $l & $r : $o eq '|' ? $l | $r : $o eq '^' ? $l ^ $r : $o eq '<<' ? $l << $r : $l >> $r;
732 }
733 64 return $l;
734 41 };
735 41 ▶ return 0 unless @t;
Branch: 1 branch
BranchTrueFalseTotal
unless @t 0 41 41
736 41 my $v = $bin->(0);
737 40 ▶ die "bash: syntax error in expression (error token is \"$t[$k]\")\n" if $k < @t;
Branch: 1 branch
BranchTrueFalseTotal
if $k < @t 0 40 40
738 40 return $v;
739 }
740  
741 # --- test / [ ] / [[ ]] ----------------------------------------------------------
742  
743  
744 62 ▶sub test_expr {
Subroutine test_expr: called CC=7 SCAR=22.1
Pod documented
745 62 my ( $args, $fi, $dbl ) = @_;
746 62 my @a = @$args;
747 62 my $k = 0;
748 62 ▶ my $name = $dbl ? '[[' : '[';
Branch: 1 branch
BranchTrueFalseTotal
$dbl ? : 8 54 62
749 62 my %un = map { $_ => 1 } qw( -e -f -d -s -r -w -x -L -h -z -n -b -c -p -S -g -u -k -O -G -N -t );
750 62 my %bin = map { $_ => 1 } qw( = == != < > -eq -ne -lt -le -gt -ge -nt -ot -ef =~ );
751 62 ▶ my $int = sub { my ($x) = @_; $x =~ /\A\s*-?\d+\s*\z/ or die "bash: $name: $x: integer expression expected\n"; 0 + $x };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$x =~ /\A\s*-?\d+\s*\z/ or die "bash: ${name}: ${x}: integer expression expected\n" 20 2 22
752 62 my ( $or, $and, $not, $prim );
753 66 ▶ $prim = sub {
Subroutine __ANON__: called CC=75 SCAR=63.5
754 66 ▶ my $x = $a[$k] // die "bash: $name: argument expected\n";
Condition50%1/2
$a[$k] // die("bash: ${name}: argument expected\n")
l!l
660
MC/DC0%0/1
$a[$k] // die("bash: ${name}: argument expected\n")
$a[$k]
Truth table50%1/2
A
A= $a[$k]
Aresult
11
00
755 66 ▶ if ( $x eq '(' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x eq "(") 0 66 66
756 0 $k++;
757 0 my $v = $or->();
758 0 ▶ ( $a[ $k++ ] // '' ) eq ')' or die "bash: $name: `)' expected\n";
Branch: 1 branch
BranchTrueFalseTotal
($a[$k++] // "") eq ")" or die "bash: ${name}: `)' expected\n" 0 0 0
Condition0%0/2
$a[$k++] // ""
l!l
00
MC/DC0%0/1
$a[$k++] // ""
$a[$k++]
Truth table0%0/2
A
A= $a[$k++]
Aresult
11
00
759 0 return $v;
760 }
761 66 ▶ if ( $un{$x} && $k + 1 < @a && !( $k + 2 < @a && $bin{ $a[ $k + 1 ] } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($un{$x} and $k + 1 < @a and not $k + 2 < @a && $bin{$a[$k + 1]}) 26 40 66
Condition66%6/9
$un{$x} and $k + 1 < @a and not $k + 2 < @a && $bin{$a[$k + 1]}
!ll&&!rl&&r
40026
$un{$x} and $k + 1 < @a
!ll&&!rl&&r
40026
$k + 2 < @a && $bin{$a[$k + 1]}
!ll&&!rl&&r
2510
MC/DC25%1/4
$un{$x} and $k + 1 < @a and not $k + 2 < @a && $bin{$a[$k + 1]}
$un{$x} $k + 1 < @a $k + 2 < @a $bin{$a[$k + 1]}
Truth table60%3/5
A and B and not(C && D)
A= $un{$x}B= $k + 1 < @aC= $k + 2 < @aD= $bin{$a[$k + 1]}
ABCDresult
0XXX0
10XX0
11110
110X1
11101
762 26 my $v = $a[ $k + 1 ];
763 26 $k += 2;
764 26 ▶ return length $v ? 0 : 1 if $x eq '-z';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-z" 1 25 26
length $v ? : 0 1 1
765 25 ▶ return length $v ? 1 : 0 if $x eq '-n';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-n" 0 25 25
length $v ? : 0 0 0
766 25 ▶ return 0 if $x eq '-t';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "-t" 0 25 25
767 25 my $f = $fi->($v);
768 25 ▶ return 0 unless $f;
Branch: 1 branch
BranchTrueFalseTotal
unless $f 8 17 25
769 17 ▶ return 1 if $x eq '-e';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "-e" 1 16 17
770 16 ▶ return $f->{kind} eq 'f' || $f->{kind} eq 'l' && ( $f->{target_kind} // 'f' ) eq 'f' ? 1 : 0 if $x eq '-f';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-f" 11 5 16
$f->{'kind'} eq 'f' || $f->{'kind'} eq 'l' && ($f->{'target_kind'} // 'f') eq 'f' ? : 11 0 11
Condition12%1/8
$f->{"kind"} eq "f" or $f->{"kind"} eq "l" and ($f->{"target_kind"} // "f") eq "f"
l!l&&r!l&&!r
1100
$f->{"kind"} eq "l" and ($f->{"target_kind"} // "f") eq "f"
!ll&&!rl&&r
000
$f->{"target_kind"} // "f"
l!l
00
MC/DC0%0/3
$f->{"kind"} eq "f" or $f->{"kind"} eq "l" and ($f->{"target_kind"} // "f") eq "f"
$f->{"kind"} eq "f" $f->{"kind"} eq "l" $f->{"target_kind"}
Truth table25%1/4
A or B and C
A= $f->{"kind"} eq "f"B= $f->{"kind"} eq "l"C= $f->{"target_kind"}
ABCresult
1XX1
0111
00X0
0100
771 5 ▶ return $f->{kind} eq 'd' || $f->{kind} eq 'l' && ( $f->{target_kind} // '' ) eq 'd' ? 1 : 0 if $x eq '-d';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-d" 2 3 5
$f->{'kind'} eq 'd' || $f->{'kind'} eq 'l' && ($f->{'target_kind'} // '') eq 'd' ? : 0 2 2
Condition25%2/8
$f->{"kind"} eq "d" or $f->{"kind"} eq "l" and ($f->{"target_kind"} // "") eq "d"
l!l&&r!l&&!r
002
$f->{"kind"} eq "l" and ($f->{"target_kind"} // "") eq "d"
!ll&&!rl&&r
200
$f->{"target_kind"} // ""
l!l
00
MC/DC0%0/3
$f->{"kind"} eq "d" or $f->{"kind"} eq "l" and ($f->{"target_kind"} // "") eq "d"
$f->{"kind"} eq "d" $f->{"kind"} eq "l" $f->{"target_kind"}
Truth table25%1/4
A or B and C
A= $f->{"kind"} eq "d"B= $f->{"kind"} eq "l"C= $f->{"target_kind"}
ABCresult
1XX1
0111
00X0
0100
772 3 ▶ return $f->{kind} eq 'l' ? 1 : 0 if $x eq '-L' || $x eq '-h';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-L" or $x eq "-h" 0 3 3
$f->{'kind'} eq 'l' ? : 0 0 0
Condition33%1/3
$x eq "-L" or $x eq "-h"
l!l&&r!l&&!r
003
MC/DC0%0/2
$x eq "-L" or $x eq "-h"
$x eq "-L" $x eq "-h"
Truth table33%1/3
A or B
A= $x eq "-L"B= $x eq "-h"
ABresult
1X1
011
000
773 3 ▶ return ( $f->{size} // 0 ) > 0 ? 1 : 0 if $x eq '-s';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-s" 2 1 3
($f->{'size'} // 0) > 0 ? : 1 1 2
Condition50%1/2
$f->{"size"} // 0
l!l
20
MC/DC0%0/1
$f->{"size"} // 0
$f->{"size"}
Truth table50%1/2
A
A= $f->{"size"}
Aresult
11
00
774 1 ▶ return 1 if $x eq '-r' || $x eq '-w';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "-r" or $x eq "-w" 0 1 1
Condition33%1/3
$x eq "-r" or $x eq "-w"
l!l&&r!l&&!r
001
MC/DC0%0/2
$x eq "-r" or $x eq "-w"
$x eq "-r" $x eq "-w"
Truth table33%1/3
A or B
A= $x eq "-r"B= $x eq "-w"
ABresult
1X1
011
000
775 1 ▶ return ( $f->{mode} // 0 ) & 0111 || $f->{kind} eq 'd' ? 1 : 0 if $x eq '-x';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-x" 1 0 1
($f->{'mode'} // 0) & 73 || $f->{'kind'} eq 'd' ? : 1 0 1
Condition40%2/5
($f->{"mode"} // 0) & 73 or $f->{"kind"} eq "d"
l!l&&r!l&&!r
100
$f->{"mode"} // 0
l!l
10
MC/DC0%0/2
($f->{"mode"} // 0) & 73 or $f->{"kind"} eq "d"
$f->{"mode"} $f->{"kind"} eq "d"
Truth table33%1/3
A or B
A= $f->{"mode"}B= $f->{"kind"} eq "d"
ABresult
1X1
011
000
776 0 ▶ return ( $f->{mode} // 0 ) & 04000 ? 1 : 0 if $x eq '-u';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-u" 0 0 0
($f->{'mode'} // 0) & 2048 ? : 0 0 0
Condition0%0/2
$f->{"mode"} // 0
l!l
00
MC/DC0%0/1
$f->{"mode"} // 0
$f->{"mode"}
Truth table0%0/2
A
A= $f->{"mode"}
Aresult
11
00
777 0 ▶ return ( $f->{mode} // 0 ) & 02000 ? 1 : 0 if $x eq '-g';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-g" 0 0 0
($f->{'mode'} // 0) & 1024 ? : 0 0 0
Condition0%0/2
$f->{"mode"} // 0
l!l
00
MC/DC0%0/1
$f->{"mode"} // 0
$f->{"mode"}
Truth table0%0/2
A
A= $f->{"mode"}
Aresult
11
00
778 0 ▶ return ( $f->{mode} // 0 ) & 01000 ? 1 : 0 if $x eq '-k';
Branch: 2 branches
BranchTrueFalseTotal
if $x eq "-k" 0 0 0
($f->{'mode'} // 0) & 512 ? : 0 0 0
Condition0%0/2
$f->{"mode"} // 0
l!l
00
MC/DC0%0/1
$f->{"mode"} // 0
$f->{"mode"}
Truth table0%0/2
A
A= $f->{"mode"}
Aresult
11
00
779 0 return 0;
780 }
781 40 ▶ if ( $k + 2 < @a + 0 && $bin{ $a[ $k + 1 ] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k + 2 < @a + 0 and $bin{$a[$k + 1]}) 39 1 40
Condition66%2/3
$k + 2 < @a + 0 and $bin{$a[$k + 1]}
!ll&&!rl&&r
0139
MC/DC50%1/2
$k + 2 < @a + 0 and $bin{$a[$k + 1]}
$k + 2 < @a + 0 $bin{$a[$k + 1]}
Truth table66%2/3
A and B
A= $k + 2 < @a + 0B= $bin{$a[$k + 1]}
ABresult
0X0
100
111
782 39 my ( $l, $o, $r ) = @a[ $k .. $k + 2 ];
783 39 $k += 3;
784 39 ▶ return ( $dbl ? $l =~ /\A${\ glob_re($r, 1)}\z/s : $l eq $r ) ? 1 : 0 if $o eq '=' || $o eq '==';
Branch: 3 branches
BranchTrueFalseTotal
if $o eq "=" or $o eq "==" 18 21 39
($dbl ? $l =~ /\A${\glob_re($r, 1);}\z/s : $l eq $r) ? : 8 10 18
$dbl ? : 2 16 18
Condition100%3/3
$o eq "=" or $o eq "=="
l!l&&r!l&&!r
16221
MC/DC100%2/2
$o eq "=" or $o eq "=="
$o eq "=" $o eq "=="
Truth table100%3/3
A or B
A= $o eq "="B= $o eq "=="
ABresult
1X1
011
000
785 0 ▶ return ( $dbl ? $l =~ /\A${\ glob_re($r, 1)}\z/s : $l eq $r ) ? 0 : 1 if $o eq '!=';
Branch: 3 branches
BranchTrueFalseTotal
if $o eq "!=" 0 21 21
($dbl ? $l =~ /\A${\glob_re($r, 1);}\z/s : $l eq $r) ? : 0 0 0
$dbl ? : 0 0 0
786 21 ▶ return ( $l lt $r ) ? 1 : 0 if $o eq '<';
Branch: 2 branches
BranchTrueFalseTotal
if $o eq "<" 7 14 21
$l lt $r ? : 5 2 7
787 14 ▶ return ( $l gt $r ) ? 1 : 0 if $o eq '>';
Branch: 2 branches
BranchTrueFalseTotal
if $o eq ">" 0 14 14
$l gt $r ? : 0 0 0
788 14 ▶ if ( $o eq '=~' ) { my $re = eval { qr/$r/ } // die "bash: $name: invalid regular expression\n"; return $l =~ $re ? 1 : 0 }
Branch: 2 branches
BranchTrueFalseTotal
if ($o eq "=~") 1 13 14
$l =~ /$re/ ? : 1 0 1
Condition50%1/2
eval { do { qr/$r/ } } // die("bash: ${name}: invalid regular expression\n")
l!l
10
MC/DC0%0/1
eval { do { qr/$r/ } } // die("bash: ${name}: invalid regular expression\n")
eval { do { qr/$r/ } }
Truth table50%1/2
A
A= eval { do { qr/$r/ } }
Aresult
11
00
789 13 ▶ if ( $o eq '-nt' || $o eq '-ot' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o eq "-nt" or $o eq "-ot") 1 12 13
Condition66%2/3
$o eq "-nt" or $o eq "-ot"
l!l&&r!l&&!r
1012
MC/DC50%1/2
$o eq "-nt" or $o eq "-ot"
$o eq "-nt" $o eq "-ot"
Truth table66%2/3
A or B
A= $o eq "-nt"B= $o eq "-ot"
ABresult
1X1
011
000
790 1 my ( $fl, $fr ) = ( $fi->($l), $fi->($r) );
791 1 ▶ return 0 unless $fl && $fr;
Branch: 1 branch
BranchTrueFalseTotal
unless $fl and $fr 0 1 1
Condition33%1/3
$fl and $fr
!ll&&!rl&&r
001
MC/DC0%0/2
$fl and $fr
$fl $fr
Truth table33%1/3
A and B
A= $flB= $fr
ABresult
0X0
100
111
792 1 ▶ return $o eq '-nt' ? ( $fl->{mtime} > $fr->{mtime} ? 1 : 0 ) : ( $fl->{mtime} < $fr->{mtime} ? 1 : 0 );
Branch: 3 branches
BranchTrueFalseTotal
$o eq '-nt' ? : 1 0 1
$fl->{'mtime'} > $fr->{'mtime'} ? : 1 0 1
$fl->{'mtime'} < $fr->{'mtime'} ? : 0 0 0
793 }
794 12 ▶ die "gap: test $o\n" if $o eq '-ef';
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "-ef" 0 12 12
795 12 my ( $x, $y ) = ( $int->($l), $int->($r) );
796 10 ▶ return { -eq => $x == $y, -ne => $x != $y, -lt => $x < $y, -le => $x <= $y, -gt => $x > $y, -ge => $x >= $y }->{$o} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
{'-eq', $x == $y, '-ne', $x != $y, '-lt', $x < $y, '-le', $x <= $y, '-gt', $x > $y, '-ge', $x >= $y}->{$o} ? : 6 4 10
797 }
798 1 $k++;
799 1 ▶ die "bash: $name: $x: unary operator expected\n" if $un{$x} && $k < @a;
Branch: 1 branch
BranchTrueFalseTotal
if $un{$x} and $k < @a 0 1 1
Condition33%1/3
$un{$x} and $k < @a
!ll&&!rl&&r
100
MC/DC0%0/2
$un{$x} and $k < @a
$un{$x} $k < @a
Truth table33%1/3
A and B
A= $un{$x}B= $k < @a
ABresult
0X0
100
111
800 1 ▶ return length $x ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
length $x ? : 1 0 1
801 62 };
802 67 ▶ $not = sub {
Subroutine __ANON__: called CC=5 SCAR=16.7
803 67 ▶ if ( ( $a[$k] // '' ) eq '!' && $k + 1 < @a ) { $k++; return $not->() ? 0 : 1 }
Branch: 2 branches
BranchTrueFalseTotal
if (($a[$k] // "") eq "!" and $k + 1 < @a) 1 66 67
&$not() ? : 0 1 1
Condition60%3/5
($a[$k] // "") eq "!" and $k + 1 < @a
!ll&&!rl&&r
6601
$a[$k] // ""
l!l
670
MC/DC0%0/2
($a[$k] // "") eq "!" and $k + 1 < @a
$a[$k] $k + 1 < @a
Truth table33%1/3
A and B
A= $a[$k]B= $k + 1 < @a
ABresult
0X0
100
111
804 66 return $prim->();
805 62 };
806 63 ▶ $and = sub {
Subroutine __ANON__: called CC=8 SCAR=21.4
807 63 my $v = $not->();
808 61 ▶ while ( $k < @a && ( $a[$k] eq '-a' && !$dbl || $a[$k] eq '&&' && $dbl ) ) { $k++; my $w = $not->(); $v = $v && $w ? 1 : 0 }
Branch: 2 branches
BranchTrueFalseTotal
if ($k < @a and $a[$k] eq "-a" && !$dbl || $a[$k] eq "&&" && $dbl) 3 61 64
$v && $w ? : 3 0 3
Condition73%11/15
$k < @a and $a[$k] eq "-a" && !$dbl || $a[$k] eq "&&" && $dbl
!ll&&!rl&&r
5923
$a[$k] eq "-a" and not $dbl or $a[$k] eq "&&" and $dbl
l!l&&r!l&&!r
122
$a[$k] eq "-a" and not $dbl
!ll&&!rl&&r
401
$a[$k] eq "&&" and $dbl
!ll&&!rl&&r
202
$v and $w
!ll&&!rl&&r
003
MC/DC60%3/5
$k < @a and $a[$k] eq "-a" && !$dbl || $a[$k] eq "&&" && $dbl
$k < @a $a[$k] eq "-a" not $dbl $a[$k] eq "&&" $dbl
MC/DC0%0/2
$v and $w
$v $w
Truth table50%4/8
A and B and not(C) or D and E
A= $k < @aB= $a[$k] eq "-a"C= not $dblD= $a[$k] eq "&&"E= $dbl
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
Truth table33%1/3
A and B
A= $vB= $w
ABresult
0X0
100
111
809 61 return $v;
810 62 };
811 62 ▶ $or = sub {
Subroutine __ANON__: called CC=8 SCAR=22.4
812 62 my $v = $and->();
813 60 ▶ while ( $k < @a && ( $a[$k] eq '-o' && !$dbl || $a[$k] eq '||' && $dbl ) ) { $k++; my $w = $and->(); $v = $v || $w ? 1 : 0 }
Branch: 2 branches
BranchTrueFalseTotal
if ($k < @a and $a[$k] eq "-o" && !$dbl || $a[$k] eq "||" && $dbl) 1 60 61
$v || $w ? : 1 0 1
Condition60%9/15
$k < @a and $a[$k] eq "-o" && !$dbl || $a[$k] eq "||" && $dbl
!ll&&!rl&&r
5911
$a[$k] eq "-o" and not $dbl or $a[$k] eq "||" and $dbl
l!l&&r!l&&!r
101
$a[$k] eq "-o" and not $dbl
!ll&&!rl&&r
101
$a[$k] eq "||" and $dbl
!ll&&!rl&&r
100
$v or $w
l!l&&r!l&&!r
100
MC/DC40%2/5
$k < @a and $a[$k] eq "-o" && !$dbl || $a[$k] eq "||" && $dbl
$k < @a $a[$k] eq "-o" not $dbl $a[$k] eq "||" $dbl
MC/DC0%0/2
$v or $w
$v $w
Truth table37%3/8
A and B and not(C) or D and E
A= $k < @aB= $a[$k] eq "-o"C= not $dblD= $a[$k] eq "||"E= $dbl
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
Truth table33%1/3
A or B
A= $vB= $w
ABresult
1X1
011
000
814 60 return $v;
815 62 };
816 62 ▶ return ( 1, undef ) unless @a;
Branch: 1 branch
BranchTrueFalseTotal
unless @a 0 62 62
817 62 my $v = eval {
818 62 my $r = $or->();
819 60 ▶ die "bash: $name: too many arguments\n" if $k < @a;
Branch: 1 branch
BranchTrueFalseTotal
if $k < @a 1 59 60
820 59 $r;
821 };
822 62 ▶ if ( my $e = $@ ) { die $e if $e =~ /\Agap:/; $e =~ s/\s+\z//; return ( 2, $e ) }
Branch: 2 branches
BranchTrueFalseTotal
if (my $e = $@) 3 59 62
if $e =~ /\Agap:/ 0 3 3
823 59 ▶ return ( $v ? 0 : 1, undef );
Branch: 1 branch
BranchTrueFalseTotal
$v ? : 34 25 59
824 }
825  
826 # --- Woerter und Kette -----------------------------------------------------------
827  
828  
829 4899 ▶sub shell_words {
Subroutine shell_words: called CC=20 SCAR=30.0
Pod documented
830 4899 my ( $s, $globs ) = @_; # $globs: je Wort 1, wenn es ungequotete * ? [ traegt (Muster fuer den Glob)
831 4899 my @w;
832 4899 my ( $cur, $have, $glob ) = ( '', 0, 0 );
833 4899 ▶ my $push = sub { if ($have) { $globs->[ scalar @w ] = $glob if $globs; push @w, $cur } ( $cur, $have, $glob ) = ( '', 0, 0 ) };
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 2 branches
BranchTrueFalseTotal
if ($have) 12687 650 13337
if $globs 12278 409 12687
834 4899 pos($s) = 0;
835 4899 ▶ while ( pos($s) < length $s ) {
Branch: 1 branch
BranchTrueFalseTotal
if (pos $s < length $s) 21227 4899 26126
836 21227 ▶ if ( $s =~ /\G[ \t]+/gc ) { $push->() }
Branch: 12 branches
BranchTrueFalseTotal
if ($s =~ /\G[ \t]+/cg) { } 8130 13097 21227
elsif (not $have and $s =~ /\G[12]?>&[12]|\G<&\d/cg) { } 13 13084 13097
elsif (not $have and $s =~ /\G2>>?[ \t]*(?:'[^']*'|"[^"]*"|[^\s|;&>]+)/cg) { } 15 13069 13084
elsif (not $have and $s =~ /\G(?:&|1)(>>?)/cg) { } 6 13063 13069
elsif ($s =~ /\G(\|\||&&|>>|[|;>\n])/cg) { } 308 12755 13063
elsif ($s =~ /\G'([^']*)'/cg) { } 450 12305 12755
elsif ($s =~ /\G"((?:[^"\\]|\\.)*)"/cg) { } 282 12023 12305
elsif ($s =~ /\G\\(.)/cgs) { } 17 12006 12023
elsif ($s =~ /\G(['"])/cg) { } 0 12006 12006
elsif ($s =~ /\G(<\()/cg) { } 3 12003 12006
elsif (not $have and $s =~ /\G0?<(?![(<])/cg) { } 14 11989 12003
elsif ($s =~ /\G([^\s'"\\|;&>]+|&)/cg) { } 11989 0 11989
837 # Umleitungen von Dateideskriptoren: die Simulation kennt nur einen Ausgabestrom.
838 # 2>&1, >&2, 2>datei und 2>/dev/null lassen ihn unveraendert; &> und 1> leiten ihn um.
839 ▶ elsif ( !$have && $s =~ /\G[12]?>&[12]|\G<&\d/gc ) { }
Condition100%3/3
not $have and $s =~ /\G[12]?>&[12]|\G<&\d/cg
!ll&&!rl&&r
571302713
MC/DC100%2/2
not $have and $s =~ /\G[12]?>&[12]|\G<&\d/cg
not $have $s =~ /\G[12]?>&[12]|\G<&\d/cg
Truth table100%3/3
not(A) and B
A= not $haveB= $s =~ /\G[12]?>&[12]|\G<&\d/cg
ABresult
0X0
100
111
840 ▶ elsif ( !$have && $s =~ /\G2>>?[ \t]*(?:'[^']*'|"[^"]*"|[^\s|;&>]+)/gc ) { }
Condition100%3/3
not $have and $s =~ /\G2>>?[ \t]*(?:'[^']*'|"[^"]*"|[^\s|;&>]+)/cg
!ll&&!rl&&r
571301215
MC/DC100%2/2
not $have and $s =~ /\G2>>?[ \t]*(?:'[^']*'|"[^"]*"|[^\s|;&>]+)/cg
not $have $s =~ /\G2>>?[ \t]*(?:'[^']*'|"[^"]*"|[^\s|;&>]+)/cg
Truth table100%3/3
not(A) and B
A= not $haveB= $s =~ /\G2>>?[ \t]*(?:'[^']*'|"[^"]*"|[^\s|;&>]+)/cg
ABresult
0X0
100
111
841 6 ▶ elsif ( !$have && $s =~ /\G(?:&|1)(>>?)/gc ) { push @w, { op => $1 } }
Condition100%3/3
not $have and $s =~ /\G(?:&|1)(>>?)/cg
!ll&&!rl&&r
57130066
MC/DC100%2/2
not $have and $s =~ /\G(?:&|1)(>>?)/cg
not $have $s =~ /\G(?:&|1)(>>?)/cg
Truth table100%3/3
not(A) and B
A= not $haveB= $s =~ /\G(?:&|1)(>>?)/cg
ABresult
0X0
100
111
842 308 ▶ elsif ( $s =~ /\G(\|\||&&|>>|[|;>\n])/gc ) { $push->(); push @w, { op => $1 eq "\n" ? ';' : $1 } }
Branch: 1 branch
BranchTrueFalseTotal
$1 eq "\n" ? : 0 308 308
843 450 elsif ( $s =~ /\G'([^']*)'/gc ) { $cur .= $1; $have = 1 }
844 282 elsif ( $s =~ /\G"((?:[^"\\]|\\.)*)"/gc ) { ( my $x = $1 ) =~ s/\\(["\\\$`])/$1/g; $cur .= $x; $have = 1 }
845 17 elsif ( $s =~ /\G\\(.)/gcs ) { $cur .= $1; $have = 1 }
846 0 elsif ( $s =~ /\G(['"])/gc ) { die "bash: unexpected EOF while looking for matching `$1'\n" }
847 3 elsif ( $s =~ /\G(<\()/gc ) { $cur .= $1; $have = 1 }
848 14 ▶ elsif ( !$have && $s =~ /\G0?<(?![(<])/gc ) { push @w, { op => '<' } } # Eingabe aus einer Datei (nur ohne Quotes)
Condition100%3/3
not $have and $s =~ /\G0?<(?![(<])/cg
!ll&&!rl&&r
71198214
MC/DC100%2/2
not $have and $s =~ /\G0?<(?![(<])/cg
not $have $s =~ /\G0?<(?![(<])/cg
Truth table100%3/3
not(A) and B
A= not $haveB= $s =~ /\G0?<(?![(<])/cg
ABresult
0X0
100
111
849 11989 ▶ elsif ( $s =~ /\G([^\s'"\\|;&>]+|&)/gc ) { $cur .= $1; $have = 1; $glob = 1 if $1 =~ /[*?\[]/ }
Branch: 1 branch
BranchTrueFalseTotal
if $1 =~ /[*?\[]/ 49 11940 11989
850 0 else { last }
851 }
852 4899 $push->();
853 4899 return @w;
854 }
855  
856  
857 25 ▶sub split_chain {
Subroutine split_chain: called CC=21 SCAR=30.6
Pod documented
858 25 my ($s) = @_;
859 25 my @out;
860 25 my ( $cur, $op, $q ) = ( '', ';', '' );
861 25 my @c = split //, $s;
862 25 ▶ for ( my $i = 0; $i < @c; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @c) 644 25 669
863 644 my $ch = $c[$i];
864 644 ▶ if ($q) { $cur .= $ch; $q = '' if $ch eq $q && ( $q eq "'" || $c[ $i - 1 ] ne '\\' ); next }
Branch: 2 branches
BranchTrueFalseTotal
if ($q) 67 577 644
if $ch eq $q and $q eq "'" || $c[$i - 1] ne "\\" 5 62 67
Condition66%4/6
$ch eq $q and $q eq "'" || $c[$i - 1] ne "\\"
!ll&&!rl&&r
6205
$q eq "'" or $c[$i - 1] ne "\\"
l!l&&r!l&&!r
320
MC/DC33%1/3
$ch eq $q and $q eq "'" || $c[$i - 1] ne "\\"
$ch eq $q $q eq "'" $c[$i - 1] ne "\\"
Truth table75%3/4
A and B or C
A= $ch eq $qB= $q eq "'"C= $c[$i - 1] ne "\\"
ABCresult
0XX0
1000
11X1
1011
865 577 ▶ if ( $ch eq "'" || $ch eq '"' ) { $q = $ch; $cur .= $ch; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "'" or $ch eq "\"") 5 572 577
Condition100%3/3
$ch eq "'" or $ch eq "\""
l!l&&r!l&&!r
32572
MC/DC100%2/2
$ch eq "'" or $ch eq "\""
$ch eq "'" $ch eq "\""
Truth table100%3/3
A or B
A= $ch eq "'"B= $ch eq "\""
ABresult
1X1
011
000
866 572 ▶ my $two = $ch . ( $c[ $i + 1 ] // '' );
Condition100%2/2
$c[$i + 1] // ""
l!l
54923
MC/DC100%1/1
$c[$i + 1] // ""
$c[$i + 1]
Truth table100%2/2
A
A= $c[$i + 1]
Aresult
11
00
867 572 ▶ if ( $two eq '&&' || $two eq '||' || $ch eq ';' || $ch eq "\n" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($two eq "&&" or $two eq "||" or $ch eq ";" or $ch eq "\n") 11 561 572
Condition88%8/9
$two eq "&&" or $two eq "||" or $ch eq ";" or $ch eq "\n"
l!l&&r!l&&!r
110561
$two eq "&&" or $two eq "||" or $ch eq ";"
l!l&&r!l&&!r
47561
$two eq "&&" or $two eq "||"
l!l&&r!l&&!r
22568
MC/DC75%3/4
$two eq "&&" or $two eq "||" or $ch eq ";" or $ch eq "\n"
$two eq "&&" $two eq "||" $ch eq ";" $ch eq "\n"
Truth table80%4/5
A or B or C or D
A= $two eq "&&"B= $two eq "||"C= $ch eq ";"D= $ch eq "\n"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
868 11 ▶ push @out, [ $op, $cur ] if $cur =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $cur =~ /\S/ 11 0 11
869 11 ▶ ( $op, $cur ) = ( $two eq '&&' || $two eq '||' ? $two : ';', '' );
Branch: 1 branch
BranchTrueFalseTotal
$two eq '&&' || $two eq '||' ? : 4 7 11
Condition100%3/3
$two eq "&&" or $two eq "||"
l!l&&r!l&&!r
227
MC/DC100%2/2
$two eq "&&" or $two eq "||"
$two eq "&&" $two eq "||"
Truth table100%3/3
A or B
A= $two eq "&&"B= $two eq "||"
ABresult
1X1
011
000
870 11 ▶ $i++ if length($two) == 2 && ( $two eq '&&' || $two eq '||' );
Branch: 1 branch
BranchTrueFalseTotal
if length $two == 2 and $two eq "&&" || $two eq "||" 4 7 11
Condition83%5/6
length $two == 2 and $two eq "&&" || $two eq "||"
!ll&&!rl&&r
074
$two eq "&&" or $two eq "||"
l!l&&r!l&&!r
227
MC/DC66%2/3
length $two == 2 and $two eq "&&" || $two eq "||"
length $two == 2 $two eq "&&" $two eq "||"
Truth table75%3/4
A and B or C
A= length $two == 2B= $two eq "&&"C= $two eq "||"
ABCresult
0XX0
1000
11X1
1011
871 11 next;
872 }
873 561 $cur .= $ch;
874 }
875 25 ▶ push @out, [ $op, $cur ] if $cur =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $cur =~ /\S/ 25 0 25
876 25 $_->[1] =~ s/\A\s+|\s+\z//g for @out;
877 25 return @out;
878 }
879  
880 84 1;
881  
882 __END__
« blib/lib/Langertha/Holmgang/Sim/Linux/Kubernetes.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Docker.pm »