Branch Coverage

lib/BATsh/SH.pm
Criterion Covered Total %
branch 144 348 41.3


line true false branch
30 0 5 if ($] < "5.006" and not defined &warnings::import)
32 0 5 if $INC[-1] eq "."
66 0 25 defined $_EXIT_CODE ? :
80 0 80 if defined $_EXIT_CODE
81 0 80 if $_BREAK or $_RETURN
88 0 80 if $line =~ /\A\s*\z/
89 0 80 if $line =~ /\A\s*#/
96 80 0 defined $first ? :
98 7 73 if ($first eq "if")
102 2 71 if ($first eq "for")
106 2 69 if ($first eq "while" or $first eq "until")
110 1 68 if ($first eq "case")
116 0 68 if $_CONTINUE
129 0 68 if $line =~ /\A\s*\z/
130 0 68 if $line =~ /\A\s*#/
133 0 68 if $line =~ /\A#!/
142 0 68 unless defined $cmd and $cmd ne ""
147 25 43 if ($cmd =~ /\A([A-Za-z_][A-Za-z0-9_]*)=(.*)\z/s)
157 24 19 if ($lc_cmd eq "export")
158 1 18 if ($lc_cmd eq "unset")
159 0 18 if ($lc_cmd eq "echo")
160 0 18 if ($lc_cmd eq "printf")
161 0 18 if ($lc_cmd eq "cd")
162 0 18 if ($lc_cmd eq "pwd")
163 0 18 if ($lc_cmd eq "exit")
164 1 17 if ($lc_cmd eq "true")
165 1 16 if ($lc_cmd eq "false")
166 0 16 if ($lc_cmd eq ":")
167 0 16 if ($lc_cmd eq "read")
168 16 0 if ($lc_cmd eq "test" or $cmd eq "[")
169 0 0 if ($lc_cmd eq "source" or $cmd eq ".")
170 0 0 $rest =~ /\A\s*(\d+)/ ? :
0 0 if ($lc_cmd eq "return")
171 0 0 if ($lc_cmd eq "break")
172 0 0 if ($lc_cmd eq "continue")
173 0 0 if ($lc_cmd eq "shift")
174 0 0 if ($lc_cmd eq "local")
175 0 0 if ($lc_cmd eq "set")
186 0 69 unless defined $str
196 0 1 if (defined $v and $v ne '') { }
201 0 0 if (not defined $v or $v eq "")
206 12 0 defined $v ? :
214 25 0 defined $v ? :
228 9 0 if ($expr =~ m[\A[\d\s\+\-\*/\%\(\)]+\z])
230 9 0 defined $result ? :
238 8 0 defined $v && $v =~ /\A-?\d+\z/ ? :
250 0 0 unless open OLD_STDOUT, ">&STDOUT"
252 0 0 unless (open CAPFH, "> $tmpfile")
262 0 0 if (open READFH, "< $tmpfile")
268 0 0 unless defined $output
280 0 24 if ($rest =~ /\A-p\s*\z/)
290 23 1 if ($item =~ /\A([A-Za-z_][A-Za-z0-9_]*)=(.*)\z/s) { }
1 0 elsif ($item =~ /\A([A-Za-z_][A-Za-z0-9_]*)\z/) { }
308 1 0 if $var ne ""
321 0 0 if ($rest =~ s/\A-n\s*//)
324 0 0 if ($rest =~ s/\A-e\s*//)
325 0 0 if ($escape)
334 0 0 if ($no_newline) { }
348 0 0 if ($rest =~ s/\A"((?:[^"\\]|\\.)*)"\s*//) { }
0 0 elsif ($rest =~ s/\A'([^']*)'\s*//) { }
356 0 0 unless defined $rest
373 0 0 if ($rest eq "" or $rest eq "~")
376 0 0 unless (chdir $rest)
392 0 0 $rest =~ /\A(\d+)/ ? :
406 0 0 unless defined $line
409 0 0 if (@vars == 1) { }
0 0 elsif (@vars > 1) { }
415 0 0 defined $words[$i] ? :
429 0 0 defined $next ? :
442 0 0 if ($rest =~ /\A([A-Za-z_][A-Za-z0-9_]*)=(.*)\z/s)
467 0 0 if (defined $opts_ref->{'_batsh'})
469 0 0 if ($@)
482 11 5 $result ? :
492 0 16 if ($expr =~ /^(.*)\s+-a\s+(.*)$/)
495 0 16 if ($expr =~ /^(.*)\s+-o\s+(.*)$/)
499 0 16 if ($expr =~ /^!\s+(.*)$/)
504 2 14 if ($expr =~ /\A(-[a-z])\s+(.+)\z/)
507 0 0 -e $path ? :
0 2 if ($op eq "-e")
508 0 0 -f $path ? :
0 2 if ($op eq "-f")
509 0 0 -d $path ? :
0 2 if ($op eq "-d")
510 0 0 -r $path ? :
0 2 if ($op eq "-r")
511 0 0 -w $path ? :
0 2 if ($op eq "-w")
512 0 0 -x $path ? :
0 2 if ($op eq "-x")
513 0 0 -s $path ? :
0 2 if ($op eq "-s")
514 1 0 !defined($s) || $s == 0 ? :
1 1 if ($op eq "-z")
515 1 0 length $path > 0 ? :
1 0 if ($op eq "-n")
516 0 0 -l $path ? :
0 0 if ($op eq "-L")
520 0 14 if ($expr =~ /\A(.+?)\s+(=|==|!=|<|>)\s+(.+)\z/)
524 0 0 $a eq $b ? :
0 0 if ($op eq "=" or $op eq "==")
525 0 0 $a ne $b ? :
0 0 if ($op eq "!=")
526 0 0 $a lt $b ? :
0 0 if ($op eq "<")
527 0 0 $a gt $b ? :
0 0 if ($op eq ">")
531 14 0 if ($expr =~ /\A(.+?)\s+(-eq|-ne|-lt|-le|-gt|-ge)\s+(.+)\z/)
535 14 0 if $a =~ /\A-?\d+\z/
536 14 0 if $b =~ /\A-?\d+\z/
537 1 1 $a == $b ? :
2 12 if ($op eq "-eq")
538 0 0 $a != $b ? :
0 12 if ($op eq "-ne")
539 5 1 $a < $b ? :
6 6 if ($op eq "-lt")
540 0 0 $a <= $b ? :
0 6 if ($op eq "-le")
541 2 0 $a > $b ? :
2 4 if ($op eq "-gt")
542 1 3 $a >= $b ? :
4 0 if ($op eq "-ge")
546 0 0 if ($expr =~ /\A-n\s+(.+)\z/)
548 0 0 length $s > 0 ? :
551 0 0 if ($expr =~ /\A-z\s+(.+)\z/)
553 0 0 length $s == 0 ? :
558 0 0 length $expr > 0 && $expr ne '0' ? :
584 0 7 if ($cond_str =~ /\A(.+?)\s*;\s*then\s+(.+?)\s*;\s*fi\s*\z/i)
587 0 0 if ($cond_status == 0)
604 16 0 $ls =~ /\A(\S+)/ ? :
606 4 12 if ($lc_first eq 'fi') { }
1 11 elsif ($lc_first eq 'elif') { }
3 8 elsif ($lc_first eq 'else') { }
0 8 elsif ($lc_first eq 'then') { }
627 6 0 $els =~ /\A(\S+)/ ? :
3 3 if (lc($els =~ /\A(\S+)/ ? $1 : "") eq "fi")
648 6 2 if ($cond_status == 0)
654 1 6 if (not $executed and defined $else_body)
674 2 0 if ($for_line =~ /\Afor\s+([A-Za-z_][A-Za-z0-9_]*)\s+in\s+(.*?)\s*(?:;\s*do)?\s*\z/i)
685 4 0 $ls =~ /\A(\S+)/ ? :
686 0 4 if ($lc_f eq "for" or $lc_f eq "while" or $lc_f eq "until")
687 2 0 if $depth == 0
2 2 if ($lc_f eq "done")
688 2 0 unless $lc_f eq "do" and $depth == 1
698 0 6 if $_BREAK or defined $_EXIT_CODE
716 1 1 $while_line =~ /\Auntil\s/i ? :
731 4 0 $ls =~ /\A(\S+)/ ? :
732 0 4 if ($lc_f eq "for" or $lc_f eq "while" or $lc_f eq "until")
733 2 0 if $depth == 0
2 2 if ($lc_f eq "done")
734 2 0 unless $lc_f eq "do" and $depth == 1
740 0 10 if defined $_EXIT_CODE
743 1 9 if $is_until and $cond_true
744 1 5 unless $is_until or $cond_true
747 0 8 if $_BREAK
767 1 0 if ($case_line =~ /\Acase\s+(.*?)\s+in\s*\z/i)
778 0 4 if $pl =~ /\A\s*\z/
779 4 0 $pl =~ /\A(\S+)/ ? :
780 1 3 if $lc_f eq "esac"
781 0 3 if $pl =~ /\A\s*;;\s*\z/
784 3 0 if ($pl =~ /\A(.*?)\)\s*(.+?)\s*;;\s*\z/)
786 2 1 unless ($matched)
789 1 1 if (_match_pattern($word, $pat))
800 0 0 if ($pl =~ /\A(.*?)\)\s*\z/)
806 0 0 if $bl =~ /\A\s*;;\s*\z/
807 0 0 if ($bl =~ /\A(.+?)\s*;;\s*\z/)
810 0 0 unless ($matched)
813 0 0 if (_match_pattern($word, $pat))
829 0 2 if $pat eq "*"
834 1 1 $word =~ /\A$re\z/ ? :
842 0 0 unless defined $rest
844 0 0 $rest ne '' ? :
847 0 0 $rc == 0 ? :
856 68 0 if ($line =~ /\A(\S+)\s*(.*)\z/s)
871 0 5 if ($@)