Branch Coverage

blib/lib/Batch/Interpreter.pm
Criterion Covered Total %
branch 0 726 0.0


line true false branch
321 0 0 unless defined $self->{'locale'}
322 0 0 if ('' eq ref(my $locale = $self->{'locale'}))
326 0 0 if ($@)
331 0 0 if $@
334 0 0 if (my(@missing) = grep((!$self->{'locale'}->can($_)), ('format_date', 'format_time_short', 'format_time', 'format_file_timedate', 'format_file_timedate_for', 'get_string')))
386 0 0 if $self->{'verbose_set'}
388 0 0 if defined $value and '' eq $value
393 0 0 defined $value ? :
0 0 if (defined $value ? defined $self->{'vars'}{$uc_var} && $self->{'vars'}{$uc_var} eq $value : !exists $self->{'vars'}{$uc_var})
403 0 0 if (defined $value) { }
411 0 0 if ($uc_var eq 'PATHEXT') { }
431 0 0 if ($short) { }
447 0 0 $_ & 1 ? :
0 0 if (my $callback = $_ & 1 ? $callback_sys : $callback_unc)
461 0 0 if (uc $$map[$i * 2 + $cmp] eq substr($mpath, 0, length $$map[$i * 2 + $cmp]))
486 0 0 if $switch_slashes
488 0 0 if (exists $self->{'filename_map'}{uc $path})
489 0 0 if defined($_ = $self->{'filename_map'}{uc $path})
493 0 0 if ('File::Spec'->file_name_is_absolute($path))
515 0 0 if (exists $self->{'filename_invmap'}{$path})
517 0 0 if defined($_ = $self->{'filename_invmap'}{$path})
521 0 0 if ('File::Spec::Win32'->file_name_is_absolute($path))
545 0 0 if (exists $self->{'filename_map'}{uc $arg})
546 0 0 if defined($_ = $self->{'filename_map'}{uc $arg})
575 0 0 if ($filter eq 'directories') { }
0 0 elsif ($filter eq 'files') { }
580 0 0 if ($do_glob) { }
634 0 0 if $name =~ /(\.[^\.]+)$/
660 0 0 ($mode // '') eq 'for' ? :
679 0 0 if ($is_win_host) { }
688 0 0 if $add_env
696 0 0 if ($opts->{'skip'})
702 0 0 unless $line =~ /\S/
704 0 0 if $opts->{'eol_re'}
708 0 0 $opts->{'delim_re'} ? :
728 0 0 unless $_[0] =~ /\G ( $any_token \s*+ ) /cgox
734 0 0 unless $_[0] =~ /\G ( (?:$re_redirect | $re_grouping | $re_string) \s*+ ) /cgox
740 0 0 unless $_[0] =~ /\G ( $re_string \s*+ ) /cgox
746 0 0 unless $_[0] =~ /\G ( $re_lhs \s*+ ) /cgox
754 0 0 unless $_[0] =~ /\G ( $re_call_arg ) $re_call_arg_separator*+ /cgox
761 0 0 unless defined $token
765 0 0 if ($q =~ /^\s+$/ and pos $token == length $token) { }
0 0 elsif ($q =~ /^\^(.)/) { }
772 0 0 $1 eq '"' ? :
774 0 0 $q =~ /\"$/ ? :
789 0 0 if ($arg =~ /[\s\"]/)
812 0 0 unless $_[0] =~ /^ ( $any_token (?: \s*+ $any_token )* ) \s* $/ox
818 0 0 unless $_[0] =~ /^ ( (?: \s*+ $any_token )* \s*+ ) \^\n $/ox
851 0 0 if ($str =~ /\G((?:\~[a-z]*)?)(\d|\*)/cig) { }
0 0 elsif ($str =~ /\G$find_end/cg) { }
853 0 0 if ($2 eq '*') { }
854 0 0 if ($1 eq '') { }
865 0 0 if ($1 eq '') { }
0 0 elsif ($1 eq '~') { }
882 0 0 $name =~ s/^(~)// ? :
887 0 0 if (exists $vars->{$uc_name}) { }
0 0 elsif ('CD' eq $uc_name) { }
0 0 elsif ('DATE' eq $uc_name) { }
0 0 elsif ('TIME' eq $uc_name) { }
0 0 elsif ('RANDOM' eq $uc_name) { }
0 0 elsif ('ERRORLEVEL' eq $uc_name) { }
0 0 elsif ('CMDEXTVERSION' eq $uc_name) { }
0 0 elsif ('CMDCMDLINE' eq $uc_name) { }
0 0 elsif ('HIGHESTNUMANODENUMBER' eq $uc_name) { }
0 0 elsif ('' eq $uc_name and not $mod and not $premod) { }
906 0 0 if $marker eq '%'
910 0 0 if defined $val and $premod eq '~'
913 0 0 if (defined $mod and defined $val)
914 0 0 if ($mod =~ /^(\*?[^=]++)\=(.*+)$/) { }
0 0 elsif ($mod =~ /^\~(-?\d++)(?:,(-?\d++))?$/) { }
916 0 0 if ($from =~ s/^\*//) { }
925 0 0 if ($offs >= 0 and $offs < length $val and $len >= 0) { }
936 0 0 if (defined $val) { }
954 0 0 unless ('File::Spec::Win32'->splitpath($filename))[2] eq $filename
974 0 0 defined $found ? :
984 0 0 unless -e $sysfile
987 0 0 if $mod =~ /s/
990 0 0 if $mod =~ /a/
991 0 0 $replace ? :
0 0 if $mod =~ /t/
993 0 0 $replace ? :
0 0 if $mod =~ /z/
995 0 0 if $mod =~ /[dpnx]/ and $replace
997 0 0 if $mod =~ /d/
998 0 0 if $mod =~ /p/
999 0 0 if $mod =~ /n/
1000 0 0 if $mod =~ /x/
1020 0 0 if ($first eq '~') { }
1021 0 0 if ($str =~ /\G$after_tilde_pat/cg and defined(my $var = $2) and $1 =~ /^([fdpnxsatz]*+)(?:\$(\w++)\:)?$/) { }
1029 0 0 if defined $path
1034 0 0 if $mod
1055 0 0 if keys %{$$self{'for_vars'};}
1058 0 0 if $self->{'delayedexpansion'}
1084 0 0 if (exists $prompt_replacement{$c}) { }
0 0 elsif ($c eq '+') { }
0 0 elsif ($c eq 'D') { }
0 0 elsif ($c eq 'M') { }
0 0 elsif ($c eq 'N') { }
0 0 elsif ($c eq 'P') { }
0 0 elsif ($c eq 'T') { }
0 0 elsif ($c eq 'V') { }
1102 0 0 if $prompt =~ /\G(.+)$/g
1118 0 0 if ($fileno == 0) { }
0 0 elsif ($fileno == 1) { }
0 0 elsif ($fileno == 2) { }
1134 0 0 if (exists $self->{'saved_handles'} and exists $self->{'saved_handles'}{'1'}) { }
1145 0 0 if (my $saved = delete $self->{'saved_handles'})
1147 0 0 if ($old = $saved->{'0'})
1150 0 0 if ($old = $saved->{'1'})
1153 0 0 if ($old = $saved->{'2'})
1174 0 0 unless defined $token and $token ne ''
1177 0 0 if ($stop)
1179 0 0 if $$stop{lc $trim}
1185 0 0 unless $start == $end
1194 0 0 unless $self->{'terminal'}
1201 0 0 if ($self->{'lines'}) { }
1203 0 0 unless defined $self->{'pos'}
1207 0 0 if $self->{'pos'} > $#{$$self{'lines'};}
1211 0 0 $is_win_host ? :
0 0 $is_continuation ? :
1225 0 0 if (defined(my $part = $self->get_raw_line($is_continuation)))
1226 0 0 if (defined(my $head = has_escaped_newline($part))) { }
1247 0 0 unless (defined $cur)
1252 0 0 unless $self->get_next_line($cur)
1257 0 0 if $$cur =~ /\G\@\s*/cg
1258 0 0 if $$cur =~ /\G\:/cg
1259 0 0 if $$cur =~ /\G\s*$/cg
1260 0 0 if $$cur =~ /\Grem\b/cig
1261 0 0 if $$cur =~ /\G\)/cig
1270 0 0 if ($$cur =~ /\Gif\b/cig) { }
0 0 elsif ($$cur =~ /\Gfor\s+/cig) { }
0 0 elsif ($$cur =~ /\G\(/cg) { }
0 0 elsif (my $statement = trace_statement($cur, $stop)) { }
1277 0 0 if ($$cur =~ /\G\s+errorlevel\s+/cig) { }
0 0 elsif ($$cur =~ /\G\s+exist\s+/cig) { }
0 0 elsif ($$cur =~ /\G\s+cmdextversion\s+/cig) { }
0 0 elsif ($$cur =~ /\G\s+defined\s+/cig) { }
1294 0 0 $not ? :
0 0 if ($not ? $$cur =~ /\G\s*+ (==) \s* /cgix : $$cur =~ /\G\s*+ (==|(?:equ|neq|lss|leq|gtr|geq)\b) \s* /cgix) { }
1312 0 0 if ($$cur =~ /\Gelse\b/cig)
1320 0 0 if ($$cur =~ m[\G/d\b]cig) { }
0 0 elsif ($$cur =~ m[\G/r\b]cig) { }
0 0 elsif ($$cur =~ m[\G/l\b]cig) { }
0 0 elsif ($$cur =~ m[\G/f\s++(?=\%)]cig) { }
0 0 elsif ($$cur =~ m[\G/f\s+]cig) { }
1336 0 0 if (defined(my $opts = next_token_string($$cur))) { }
1351 0 0 unless $$cur =~ /\G\s*+\%([a-zA-Z])\s++in\s++\(/cig
1360 0 0 if ($$cur =~ /\G( (?: [^\)\"\^]+ | $re_quotesc )+ )/cgox)
1365 0 0 if ($$cur =~ /\G([^\)]*+)\)/cg)
1375 0 0 unless $self->get_next_line($cur, 'continuation')
1378 0 0 unless $$cur =~ /\G\s*do\s+/cig
1388 0 0 if $sub eq ')'
1389 0 0 if ref $sub
1392 0 0 if $$cur =~ /\G\s*+\)/cg
1395 0 0 unless $self->get_next_line($cur, 'continuation')
1416 0 0 if ($$cur =~ /\G\s*+( (?:(?!\^)\|\|?) | (?:(?!\^)\&\&?) )/cgix)
1420 0 0 if ($1 eq '|') { }
1423 0 0 $1 eq '&&' ? :
0 0 $1 eq '&' ? :
1435 0 0 unless $str =~ /[\<\>]/
1445 0 0 unless defined $token and $token ne ''
1448 0 0 if ($token =~ /^ ( \< | \d?\>\>? ) (.*) /xi) { }
1450 0 0 if $val =~ /^\s*+$/
1451 0 0 if ($val // '') =~ /^\s*+$/
1462 0 0 if ($op eq '<') { }
0 0 elsif ($op =~ /^(\d)?(\>\>?)$/) { }
1464 0 0 unless open $fh, '<:crlf', $self->unc2sys($fn)
1471 0 0 if ($fn =~ /^\&(\d?)/) { }
1473 0 0 if ($1 eq '1') { }
1485 0 0 unless $ok
1514 0 0 if ('' eq ref $cmd) { }
0 0 elsif ($cmd->{'type'} eq 'if') { }
0 0 elsif ($cmd->{'type'} eq 'for') { }
0 0 elsif ($cmd->{'type'} eq '(') { }
0 0 elsif ($cmd->{'type'} ne 'simple') { }
1515 0 0 if ($cmd eq 'return' and @{$self->{'call_stack'};})
1519 0 0 if ($call->{'recursion'}) { }
1537 0 0 !exists $cmd->{'content'} ? :
1539 0 0 defined $content ? :
1540 0 0 if ($mode eq 'errorlevel') { }
0 0 elsif ($mode eq 'exist') { }
0 0 elsif ($mode eq 'cmdextversion') { }
0 0 elsif ($mode eq 'defined') { }
1541 0 0 unless defined $content and $content =~ /^\d++$/
1549 0 0 unless defined $content and $content =~ /^\d++$/
1563 0 0 $uc ? :
1565 0 0 if ($mode eq '==') { }
1568 0 0 if ("$op1$op2" =~ /^\d++$/) { }
1569 0 0 $mode eq 'geq' ? :
0 0 $mode eq 'gtr' ? :
0 0 $mode eq 'leq' ? :
0 0 $mode eq 'lss' ? :
0 0 $mode eq 'neq' ? :
0 0 $mode eq 'equ' ? :
1577 0 0 $mode eq 'geq' ? :
0 0 $mode eq 'gtr' ? :
0 0 $mode eq 'leq' ? :
0 0 $mode eq 'lss' ? :
0 0 $mode eq 'neq' ? :
0 0 $mode eq 'equ' ? :
1587 0 0 if $cmd->{'not'}
1590 0 0 $cmd->{'not'} ? :
0 0 if $cmd->{'echo'}
1593 0 0 if ($true) { }
0 0 elsif ($cmd->{'else'}) { }
1614 0 0 if (not $is_glob and $mode ne 'recursive') { }
1626 0 0 unless $result eq 'next'
1628 0 0 !($mode =~ /^(?:files|directories|recursive)$/) ? :
1630 0 0 if ($mode eq 'files' or $mode eq 'directories') { }
0 0 elsif ($mode eq 'recursive') { }
0 0 elsif ($mode eq 'numbers') { }
0 0 elsif ($mode eq 'lines') { }
1632 0 0 $mode eq 'directories' ? :
0 0 if $cmd->{'echo'}
1643 0 0 if $cmd->{'echo'}
1651 0 0 unless -d $_
1675 0 0 if $cmd->{'echo'}
1679 0 0 $step < 0 ? :
0 0 $step > 0 ? :
1687 0 0 unless $result eq 'next'
1692 0 0 if $cmd->{'echo'}
1700 0 0 if $opts =~ /\beol=(.)/i
1701 0 0 if $opts =~ /\bskip=(\d+)/i
1702 0 0 if $opts =~ /\bdelims=(.?[^\s]*)/i
1704 0 0 if $opts =~ /\btokens=(\d[\d,-]*+\*?)/i
1705 0 0 if $opts =~ /\busebackq\b/i
1708 0 0 if $opt{'eol'}
1710 0 0 if $opt{'delims'} ne ''
1713 0 0 /^(\d+)\-(\d+)$/ ? :
1716 0 0 if ($token[-1] =~ s/\*$//) { }
1718 0 0 if $token[-1] eq ''
1737 0 0 if ($list =~ /^\s*\"/s and $list =~ /\"\s*+$/s) { }
0 0 elsif ($usebackq and $list =~ /^\s*\`/s and $list =~ /\`\s*+$/s) { }
1754 0 0 if ($type eq 'explicit') { }
0 0 elsif ($type eq 'files') { }
1755 0 0 if (my(@val) = extract_for_tokens(\%opt, $list))
1758 0 0 unless $result eq 'next'
1765 0 0 unless open my $fh, '<:crlf', $self->unc2sys($token)
1772 0 0 unless my(@val) = extract_for_tokens(\%opt, $_)
1779 0 0 unless $result eq 'next'
1794 0 0 if $result ne 'next'
1801 0 0 unless my(@val) = extract_for_tokens(\%opt, $_)
1805 0 0 unless $result eq 'next'
1814 0 0 if 'ARRAY' eq ref $rest
1815 0 0 unless $rest eq ''
1820 0 0 if $cmd->{'echo'}
1826 0 0 unless $result eq 'next'
1836 0 0 if 'ARRAY' eq ref $cur
1841 0 0 if $cur =~ /\G$/cg
1846 0 0 if $cmd->{'echo'}
1853 0 0 unless defined $qcommand
1871 0 0 if ($lc_qcommand eq 'call') { }
0 0 elsif ($lc_qcommand eq 'goto' or $lc_qcommand eq 'exit') { }
0 0 elsif ($cur =~ /\Gecho\b/cig) { }
1872 0 0 if (@arg and $arg[0] =~ /^\:(\w+)$/) { }
1876 0 0 unless defined $index
1894 0 0 if ($cmd->{'is_child'}) { }
1904 0 0 unless $result eq 'return'
1921 0 0 if (defined $qcommand) { }
1934 0 0 if ($lc_qcommand eq 'goto') { }
1941 0 0 unless $b
1945 0 0 if ($return)
1947 0 0 unless @{$self->{'call_stack'};}
1952 0 0 if ($call->{'recursion'}) { }
1965 0 0 unless defined $index
1971 0 0 if ($cur =~ /\G\s*+$/cg) { }
0 0 elsif ($cur =~ /\G\s+on\s*+$/cig) { }
0 0 elsif ($cur =~ /\G\s+off\s*+$/cig) { }
0 0 elsif ($cur =~ /\G\.\s*+$/cg) { }
0 0 elsif ($cur =~ /\G\s/cg) { }
1973 0 0 $self->{'echo'} ? :
1991 0 0 if (my $interpreter = $self->get_interpreter_for_extension($command, \@arg, $qcommand, \@qarg))
2003 0 0 $turn ? :
2004 0 0 unless (exists $handlers->{$key} and defined($handler = $handlers->{$key}))
2007 0 0 if $turn++ > 100
2013 0 0 if ('CODE' eq ref $handler) { }
0 0 elsif ('' eq ref $handler) { }
2017 0 0 if ('HASH' eq ref $ret) { }
0 0 elsif ('' eq ref $ret and defined $ret) { }
2018 0 0 if ($ret->{'type'} eq 'rewrite')
2023 0 0 if $ret->{'env'}
2027 0 0 if $ret =~ /^error/
2029 0 0 unless $ret eq 'keep'
2046 0 0 if $ret =~ /^error/
2048 0 0 unless $ret eq 'keep'
2056 0 0 unless ($self->{'assume_is_executable'}{uc $exe} or -f $exe)
2067 0 0 unless $command =~ /\.(\w)$/
2071 0 0 unless my $handler = $self->{'extension_handlers'}{$ext}
2074 0 0 -f $self->unc2sys($command) ? :
2077 0 0 unless my($interpreter, @addarg) = &$handler($self, $found_command, $args, $qcommand, $qargs)
2080 0 0 unless defined $interpreter
2117 0 0 if ($is_win_host) { }
2120 0 0 if $self->{'verbose_system'}
2126 0 0 if $self->{'verbose_system'}
2130 0 0 if ($attr->{'flip_stdin'} and not defined $result)
2133 0 0 unless ($pid // 1)
2142 0 0 if (defined $pid) { }
2150 0 0 if ($attr->{'flip_stdout'} and not defined $result)
2153 0 0 unless ($pid // 1)
2162 0 0 if (defined $pid) { }
2170 0 0 if ($attr->{'flip_stderr'} and not defined $result)
2173 0 0 unless ($pid // 1)
2182 0 0 if (defined $pid) { }
2191 0 0 unless (defined $result)
2227 0 0 if my $drive = lc($args->[0] // '') eq '/d'
2229 0 0 if (not @$args) { }
0 0 elsif (@$args > 1) { }
2236 0 0 unless $self->set_curdir($dir)
2245 0 0 unless @$args == 1
2252 0 0 unless unlink $self->unc2sys($file)
2261 0 0 unless @$args == 1
2276 0 0 unless $ok
2286 0 0 unless defined $src and defined $dest and not @$args
2290 0 0 if -e $dest
2294 0 0 if (lc $command eq 'copy') { }
2296 0 0 unless copy(map($self->unc2sys($_), $src, $dest))
2299 0 0 unless move(map($self->unc2sys($_), $src, $dest))
2309 0 0 unless @$args == 1
2316 0 0 unless rmdir $self->unc2sys($file)
2325 0 0 if ($cur =~ /\G\s*+([^\=\s]*+)\s*+$/cg)
2326 0 0 $1 ? :
2329 0 0 if $filter
2338 0 0 if $arith and $prompt
2343 0 0 unless ($arith)
2344 0 0 if $set =~ s/^\s*+\"//
2347 0 0 unless $set =~ s/^\s*+([^\=\s]++)\s*+\=//g
2353 0 0 if $prompt
2377 0 0 unless $expr =~ m[\G\s*+ ([^\s\*/\%\+\-\&\^\|\<\>]+) \s*+ (|\*|/|\%|\+|\-|\&|\^|\||\<\<|\>\>)\= (.*) ]cgx
2387 0 0 if $op
2404 0 0 unless $rhs =~ /^[0-9\s\Q$opchar\E]+$/o
2411 0 0 if $@
2569 0 0 $is_win_host ? :
2584 0 0 if $pattern =~ s/^([^\[]*+)\[([^\]]*+)\]$/$1$2/
2600 0 0 if ($rest and $arg =~ m[^/\+(\d+)$]) { }
0 0 elsif ($rest and is_shortened('/L[OCALE]', $arg)) { }
0 0 elsif ($rest and is_shortened('/M[EMORY]', $arg)) { }
0 0 elsif (is_shortened('/REC[ORD_MAXIMUM]', $arg)) { }
0 0 elsif (is_shortened('/R[EVERSE]', $arg)) { }
0 0 elsif ($rest and is_shortened('/T[EMPORARY]', $arg)) { }
0 0 elsif ($rest and is_shortened('/O[UTPUT]', $arg)) { }
2623 0 0 if ($splice) { }
2674 0 0 if ($pseudo_pipe) { }
2684 0 0 unless defined $pid
2686 0 0 unless ($pid // 1)
2687 0 0 unless $pseudo_pipe
2698 0 0 unless $pseudo_pipe
2702 0 0 unless $pseudo_pipe
2720 0 0 if $self->{'dump_parse_tree'} and ref $cmd
2725 0 0 unless $result eq 'next'
2727 0 0 unless $cmd->{'next_cmd'}
2729 0 0 if (defined $cmd->{'next_if'})
2730 0 0 if ($cmd->{'next_if'} eq 'ok') { }
2731 0 0 unless $self->{'exit_value'}
2733 0 0 if $self->{'exit_value'}
2749 0 0 if ($result eq 'return') { }
0 0 elsif ($result =~ /^error/g) { }
0 0 elsif ($result =~ /^exit/) { }
2767 0 0 unless ($attr->{'quoted_arguments'})
2774 0 0 if @arg and defined $arg[0]
2778 0 0 if ($lines and @$lines > 1)
2804 0 0 if (not $@) { }
0 0 elsif ($@ =~ /^EXIT: (\d+)\s/) { }
2819 0 0 if $result eq 'next' or $result eq 'return'