| 1 | package Proc::ShellSpawn::Programs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # echo, printf, test and [ (and true, false) as GNU coreutils 9.4 does them, inside the Perl process (X21; the user, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # 2026-11-08). The subset runs them as programs, and their behaviour is part of the subset's meaning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # (large-subset-state.md, section 2), so these follow coreutils, not the shells' builtins. Each function takes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # (ARGV, ENV, OPT) and returns (STDOUT, STDERR, STATUS, ORDER), ORDER (printf only; else undef) the same text as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # [FD, TEXT] pieces in the order coreutils writes them: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # ARGV the command's words, ARGV->[0] its name as written (the messages name it so, as coreutils does) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # ENV the command's environment (a hash): POSIXLY_CORRECT for echo, LC_ALL/LC_CTYPE/LC_MESSAGES/LANG for quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # OPT { isatty => CODE } for test -t FD (the command's FD, not Perl's); { cwd => DIR }: test's relative file names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # are taken from DIR (the shell's directory, not Perl's) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # Differences known (doc/pspawn-known-issues.md, X21): --help and --version print a short text; printf's floating | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # conversions use Perl's double (coreutils: long double); %q follows gnulib's fixed rule (decision IP2). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Integers go through Perl's own sprintf, so a perl with 64-bit integers is assumed (ivsize 8: Strawberry, Linux). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 443 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 443 | ▶ | use POSIX (); use File::Spec (); use Math::BigInt (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 443 | our $VERSION = '0.13'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 443 | my $IMAX = Math::BigInt->new('9223372036854775807'); my $IMIN = -$IMAX - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 443 | my $UMAX = Math::BigInt->new('18446744073709551615'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 443 | my %CESC = ("\a" => 'a', "\b" => 'b', "\f" => 'f', "\n" => 'n', "\r" => 'r', "\t" => 't', "\013" => 'v'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 443 | my $UTF8 = qr/[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xec\xee\xef][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |\xf0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2}/x; # one valid character | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1359 | ▶ | sub utf8_locale { my ($env, @cat) = @_; (grep $_, map $env->{$_}, 'LC_ALL', @cat, 'LANG')[0] // '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
utf8_locale: called CC=2 SCAR=6.9
Pod
undocumented
Condition100%2/2
(grep $_, map($env->{$_}, "LC_ALL", @cat, "LANG"))[0] // ""
MC/DC100%1/1
(grep $_, map($env->{$_}, "LC_ALL", @cat, "LANG"))[0] // ""
(grep $_, map($env->{$_}, "LC_ALL", @cat, "LANG"))[0]
Truth table100%2/2
A
A= (grep $_, map($env->{$_}, "LC_ALL", @cat, "LANG"))[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1359 | ▶ | sub is_utf8 { utf8_locale(@_) =~ /utf-?8/i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_utf8: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4993 | ▶ | sub printable { my ($c, $u) = @_; # a character (one byte, or a valid UTF-8 sequence in a UTF-8 locale) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printable: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4993 | ▶ | return $c =~ /\A[\x20-\x7e]\z/ if length $c == 1; return 0 unless $u; utf8::decode($c); $c =~ /\A\p{Print}\z/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1331 | ▶ | sub chars { my ($s, $u) = @_; $u ? $s =~ /$UTF8|./gs : split //, $s } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chars: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 82 | ▶ | sub c_esc { my ($s, $t) = @_; # bytes that cannot be printed: each as C's escape from the table %$t, else in octal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
c_esc: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 82 | ▶ | join '', map $t->{$_} ? "\\$t->{$_}" : sprintf('\\%03o', ord), split //, $s } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # "The same file?" is Proc::ShellSpawn's files_eq (the user, 2026-11-14: who uses whom decides the place), loaded only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # when test -ef or pwd -L asks: everything else here runs without that module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 26 | ▶ | sub files_eq { require Proc::ShellSpawn; Proc::ShellSpawn::files_eq(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files_eq: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1305 | ▶ | sub q_ { my ($env, $s) = @_; # coreutils' quote(): 'x' in the C locale, curly quotes in a UTF-8 one; inside, a backslash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
q_: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # doubled, control characters as C escapes, what the locale cannot print in octal, and (C locale) \' for ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1305 | my $u = is_utf8($env, 'LC_MESSAGES'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | my $t = join '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1305 | ▶ | map { printable($_, $u) ? ($_ eq '\\' ? '\\\\' : $_ eq "'" && !$u ? "\\'" : $_) : c_esc($_, \%CESC) } chars($s, $u); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$_ eq "'" and not $u
MC/DC100%2/2
$_ eq "'" and not $u
$_ eq "'"
not $u
Truth table100%3/3
A and not(B)
A= $_ eq "'"B= not $u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1305 | ▶ | $u ? "\xe2\x80\x98$t\xe2\x80\x99" : "'$t'" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # ------------------------------------------------------------------ echo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # OPT's echo (Proc::ShellSpawn: PROC_SHELLSPAWN_ECHO; decision EC1, the user, 2026-11-09) picks whose echo this is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # coreutils (the default): coreutils 9.4's; POSIXLY_CORRECT in ENV changes it (escapes always, options only a first -n) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # dash: dash 0.5.12's builtin: escapes always (not \x), options only a first -n; POSIXLY_CORRECT changes nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # bash: bash 5.2's builtin (xpg_echo off, as bash --posix starts): options -n -e -E, escapes with -e (also \E, \u, \U) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 443 | our @ECHO = qw(coreutils dash bash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1649 | ▶ | sub echo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
echo: called CC=26 SCAR=32.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1649 | ▶ | my ($argv, $env, $opt) = @_; $env //= {}; my $style = ($opt && $opt->{echo}) || 'coreutils'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition71%5/7
$env //= {}
$opt && $opt->{'echo'} || 'coreutils'
$opt and $opt->{"echo"}
MC/DC0%0/1
$env //= {}
$env
MC/DC50%1/2
$opt && $opt->{'echo'} || 'coreutils'
$opt
$opt->{"echo"}
Truth table50%1/2
A
A= $env
Truth table66%2/3
A and B
A= $optB= $opt->{"echo"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1649 | my @a = @$argv[1 .. $#$argv]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1649 | ▶ | my ($nl, $esc, $mode) = (1, 0, $style eq 'coreutils' ? 'echo' : $style); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1649 | ▶ | if ($style eq 'dash') { $esc = 1; if (@a && $a[0] eq '-n') { shift @a; $nl = 0 } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
@a and $a[0] eq "-n"
MC/DC100%2/2
@a and $a[0] eq "-n"
@a
$a[0] eq "-n"
Truth table100%3/3
A and B
A= @aB= $a[0] eq "-n"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 368 | ▶ | elsif ($style eq 'bash') { while (@a && $a[0] =~ /^-([eEn]+)\z/) { shift @a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@a and $a[0] =~ /^-([eEn]+)\z/
MC/DC100%2/2
@a and $a[0] =~ /^-([eEn]+)\z/
@a
$a[0] =~ /^-([eEn]+)\z/
Truth table100%3/3
A and B
A= @aB= $a[0] =~ /^-([eEn]+)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 174 | ▶ | for (split //, $1) { $_ eq 'n' ? ($nl = 0) : ($esc = $_ eq 'e') } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | elsif ($style eq 'coreutils') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 425 | my $posix = defined $env->{POSIXLY_CORRECT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 425 | $esc = $posix; # POSIXLY_CORRECT: escapes always, options only for a first -n | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 425 | ▶ | if (!$posix || (@a && $a[0] eq '-n')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $posix or @a and $a[0] eq "-n"
@a and $a[0] eq "-n"
MC/DC100%3/3
not $posix or @a and $a[0] eq "-n"
not $posix
@a
$a[0] eq "-n"
Truth table100%4/4
not(A) or B and C
A= not $posixB= @aC= $a[0] eq "-n"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if (my @i = info('echo', @a)) { return @i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 370 | ▶ | while (@a && $a[0] =~ /^-([eEn]+)\z/) { shift @a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@a and $a[0] =~ /^-([eEn]+)\z/
MC/DC100%2/2
@a and $a[0] =~ /^-([eEn]+)\z/
@a
$a[0] =~ /^-([eEn]+)\z/
Truth table100%3/3
A and B
A= @aB= $a[0] =~ /^-([eEn]+)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 139 | ▶ | for (split //, $1) { $_ eq 'n' ? ($nl = 0) : ($esc = $_ eq 'e' || $posix) } } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_ eq 'e' || $posix
MC/DC100%2/2
$_ eq 'e' || $posix
$_ eq 'e'
$posix
Truth table100%3/3
A || B
A= $_ eq 'e'B= $posix
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | else { die "PROC_SHELLSPAWN_ECHO: '$style' is none of @ECHO\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1649 | my $out = join ' ', @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1649 | ▶ | if ($esc) { ($out, my $stop) = esc($out, $mode, $env); return ($out, '', 0) if $stop } # \c: nothing more, not the newline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1577 | ▶ | ($out . ($nl ? "\n" : ''), '', 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # The backslash escapes of echo -e and printf's %b (MODE 'echo' or 'b'), or of printf's format ('fmt'); of dash's and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # bash's builtin echo (MODE 'dash', 'bash'). Returns (TEXT, STOP, ERROR): STOP after \c, ERROR for printf's "missing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # hexadecimal number" and "invalid universal character name". ENV: the command's environment, for \u and \U (the locale). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 443 | my %SIMPLE = (a => "\a", b => "\b", e => "\e", f => "\f", n => "\n", r => "\r", t => "\t", v => "\013", '\\' => '\\'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1960 | ▶ | sub esc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
esc: called CC=26 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1960 | ▶ | my ($s, $mode, $env) = @_; my $o = ''; my $printf = $mode eq 'b' || $mode eq 'fmt'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mode eq 'b' || $mode eq 'fmt'
MC/DC100%2/2
$mode eq 'b' || $mode eq 'fmt'
$mode eq 'b'
$mode eq 'fmt'
Truth table100%3/3
A || B
A= $mode eq 'b'B= $mode eq 'fmt'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1960 | ▶ | my $oct = $mode eq 'fmt' ? qr/([0-7]{1,3})/ : $mode eq 'bash' ? qr/0([0-7]{0,3})/ # bash: \1 stays as it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | : qr/0([0-7]{0,3})|([1-7][0-7]{0,2})/; # echo, dash and %b: \0NNN or \NNN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1960 | ▶ | while ($s =~ /\G(?:([^\\]+)|\\)/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2676 | ▶ | if (defined $1) { $o .= $1; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1406 | ▶ | if ($s =~ /\G$oct/gc) { $o .= chr(oct('0' . ($1 // $2)) & 255) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
Condition100%3/3
$1 // $2
MC/DC100%2/2
$1 // $2
$1
$2
Truth table100%3/3
A // B
A= $1B= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1010 | elsif ($s =~ /\G([abefnrtv\\])/gc) { $o .= $SIMPLE{$1} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 76 | elsif ($s =~ /\Gc/gc) { return ($o, 1) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | elsif ($mode eq 'bash' && $s =~ /\GE/gc) { $o .= "\e" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mode eq "bash" and $s =~ /\GE/cg
MC/DC100%2/2
$mode eq "bash" and $s =~ /\GE/cg
$mode eq "bash"
$s =~ /\GE/cg
Truth table100%3/3
A and B
A= $mode eq "bash"B= $s =~ /\GE/cg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 20 | ▶ | elsif ($mode ne 'dash' && $s =~ /\Gx([0-9A-Fa-f]{1,2})/gc) { $o .= chr hex $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mode ne "dash" and $s =~ /\Gx([0-9A-Fa-f]{1,2})/cg
MC/DC100%2/2
$mode ne "dash" and $s =~ /\Gx([0-9A-Fa-f]{1,2})/cg
$mode ne "dash"
$s =~ /\Gx([0-9A-Fa-f]{1,2})/cg
Truth table100%3/3
A and B
A= $mode ne "dash"B= $s =~ /\Gx([0-9A-Fa-f]{1,2})/cg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 22 | ▶ | elsif ($mode eq 'bash' && $s =~ /\G(?:u([0-9A-Fa-f]{1,4})|U([0-9A-Fa-f]{1,8}))/gc) { $o .= bash_unichar(hex($1 // $2), $env) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$mode eq "bash" and $s =~ /\G(?:u([0-9A-Fa-f]{1,4})|U([0-9A-Fa-f]{1,8}))/cg
$1 // $2
MC/DC100%2/2
$mode eq "bash" and $s =~ /\G(?:u([0-9A-Fa-f]{1,4})|U([0-9A-Fa-f]{1,8}))/cg
$mode eq "bash"
$s =~ /\G(?:u([0-9A-Fa-f]{1,4})|U([0-9A-Fa-f]{1,8}))/cg
MC/DC0%0/2
$1 // $2
$1
$2
Truth table100%3/3
A and B
A= $mode eq "bash"B= $s =~ /\G(?:u([0-9A-Fa-f]{1,4})|U([0-9A-Fa-f]{1,8}))/cg
Truth table66%2/3
A // B
A= $1B= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ▶ | elsif ($printf && $s =~ /\G(?:(u)([0-9A-Fa-f]{4})|(U)([0-9A-Fa-f]{8}))/gc) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$printf and $s =~ /\G(?:(u)([0-9A-Fa-f]{4})|(U)([0-9A-Fa-f]{8}))/cg
MC/DC100%2/2
$printf and $s =~ /\G(?:(u)([0-9A-Fa-f]{4})|(U)([0-9A-Fa-f]{8}))/cg
$printf
$s =~ /\G(?:(u)([0-9A-Fa-f]{4})|(U)([0-9A-Fa-f]{8}))/cg
Truth table100%3/3
A and B
A= $printfB= $s =~ /\G(?:(u)([0-9A-Fa-f]{4})|(U)([0-9A-Fa-f]{8}))/cg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 26 | ▶ | my ($k, $h) = defined $1 ? ($1, $2) : ($3, $4); my $v = hex $h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 26 | ▶ | return ($o, 0, "invalid universal character name \\$k\L$h") if $v >= 0xd800 && $v <= 0xdfff; # (coreutils: \%c%0*x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$v >= 55296 and $v <= 57343
MC/DC100%2/2
$v >= 55296 and $v <= 57343
$v >= 55296
$v <= 57343
Truth table100%3/3
A and B
A= $v >= 55296B= $v <= 57343
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 20 | $o .= unichar($v, $env) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 6 | ▶ | elsif ($printf && $s =~ /\G[xuU]/gc) { return ($o, 0, 'missing hexadecimal number in escape') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$printf and $s =~ /\G[xuU]/cg
MC/DC100%2/2
$printf and $s =~ /\G[xuU]/cg
$printf
$s =~ /\G[xuU]/cg
Truth table100%3/3
A and B
A= $printfB= $s =~ /\G[xuU]/cg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | elsif ($mode eq 'fmt' && $s =~ /\G"/gc) { $o .= '"' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$mode eq "fmt" and $s =~ /\G"/cg
MC/DC0%0/2
$mode eq "fmt" and $s =~ /\G"/cg
$mode eq "fmt"
$s =~ /\G"/cg
Truth table66%2/3
A and B
A= $mode eq "fmt"B= $s =~ /\G"/cg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 158 | else { $o .= '\\' } # anything else (and a final backslash): the backslash as it is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1872 | ($o, 0) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 22 | ▶ | sub bash_unichar { # bash 5.2's \u and \U in echo -e (u32cconv): ASCII as it is; in a UTF-8 locale (LC_CTYPE) the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bash_unichar: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # character in UTF-8's old form up to 6 bytes (surrogates too), else the escape \uXXXX or \UXXXXXXXX; above 0x7FFFFFFF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # nothing (checked against bash 5.2.21 in C and C.UTF-8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 22 | my ($v, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 22 | ▶ | return '' if $v > 0x7fffffff; return chr $v if $v < 0x80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 16 | ▶ | return sprintf($v <= 0xffff ? '\\u%04X' : '\\U%08X', $v) unless is_utf8($env, 'LC_CTYPE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 8 | my $c = chr $v; utf8::encode($c); $c } # (Perl's own encoder writes that old form; utf8::encode is built in: no module) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 20 | ▶ | sub unichar { # gnulib's print_unicode_char, as coreutils 9.4's printf uses it (X37): ASCII as it is; another character | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unichar: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # encoded where the locale can (here: a UTF-8 locale), else (the C locale) the escape \uXXXX or \UXXXXXXXX, as above | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # U+10FFFF everywhere. (A legacy locale such as ISO-8859-1, which coreutils would convert to by iconv, gets the escape.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 20 | my ($v, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 20 | ▶ | return chr $v if $v < 0x80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 14 | ▶ | if ($v <= 0x10ffff && is_utf8($env // {}, 'LC_CTYPE')) { my $c = chr $v; utf8::encode($c); return $c } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$v <= 1114111 and is_utf8($env // {}, "LC_CTYPE")
$env // {}
MC/DC100%2/2
$v <= 1114111 and is_utf8($env // {}, "LC_CTYPE")
$v <= 1114111
is_utf8($env // {}, "LC_CTYPE")
MC/DC0%0/1
$env // {}
$env
Truth table100%3/3
A and B
A= $v <= 1114111B= is_utf8($env // {}, "LC_CTYPE")
Truth table50%1/2
A
A= $env
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | ▶ | sprintf $v < 0x10000 ? '\u%04X' : '\U%08X', $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # ------------------------------------------------------------------ printf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # coreutils' printf.c: the flags each conversion takes (' and I not with a A c e E o s x X, # not with c d i s u, 0 not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # with c s, a precision not with c); %b and %q take nothing between % and the letter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 443 | my %NOT = ("'" => 'aAceEosxX', I => 'aAceEosxX', '#' => 'cdisu', 0 => 'cs'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1142 | ▶ | sub printf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printf: called CC=43 SCAR=37.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1142 | ▶ | my ($argv, $env) = @_; $env //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$env //= {}
MC/DC0%0/1
$env //= {}
$env
Truth table50%1/2
A
A= $env
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1142 | my ($name, @a) = @$argv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if (my @i = info('printf', @a)) { return @i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1142 | ▶ | shift @a if @a && $a[0] eq '--'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@a and $a[0] eq "--"
MC/DC100%2/2
@a and $a[0] eq "--"
@a
$a[0] eq "--"
Truth table100%3/3
A and B
A= @aB= $a[0] eq "--"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1142 | ▶ | return ('', "$name: missing operand\nTry '$name --help' for more information.\n", 1) unless @a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1140 | my $fmt = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1140 | my ($out, $err, $bad, $flushed, @seq) = ('', '', 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1140 | ▶ | my $msg = sub { push @seq, [1, substr $out, $flushed], [2, "$name: $_[0]\n"]; $flushed = length $out; $err .= "$name: $_[0]\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1140 | ▶ | my $warn = sub { $msg->(q_($env, $_[0]) . ": $_[1]"); $bad = 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1140 | ▶ | my $done = sub { ($out, $err, $_[0] // $bad, [@seq, [1, substr $out, $flushed]]) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Condition66%2/3
$_[0] // $bad
MC/DC0%0/2
$_[0] // $bad
$_[0]
$bad
Truth table66%2/3
A // B
A= $_[0]B= $bad
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1936 | ▶ | my $num = sub { # an argument as a number, with coreutils' messages; KIND i (intmax_t), u (uintmax_t), f (double) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=22 SCAR=30.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1936 | my ($s, $kind) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1936 | ▶ | return 0 if !defined $s || $s eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $s or $s eq ""
MC/DC100%2/2
not defined $s or $s eq ""
not defined $s
$s eq ""
Truth table100%3/3
not(A) or B
A= not defined $sB= $s eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1314 | ▶ | if ($s =~ /^\s*['"](.)(.*)/s) { # 'c: the character's code (a warning for more, the status kept) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 36 | ▶ | $msg->("warning: $2: character(s) following character constant have been ignored") if length $2; return ord $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1278 | ▶ | if ($kind eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 566 | ▶ | my ($v, $left) = POSIX::strtod($s); $left //= length $s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$left //= length $s
MC/DC0%0/2
$left //= length $s
$left
length $s
Truth table33%1/3
A //= B
A= $leftB= length $s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 566 | ▶ | $warn->($s, $left == length $s ? 'expected a numeric value' : 'value not completely converted') if $left; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 566 | ▶ | return $left == length $s ? 0 : $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | my ($sign, $body, $rest) = $s =~ /^\s*([-+]?)(0[xX][0-9A-Fa-f]+|0[0-7]*|[1-9][0-9]*)(.*)\z/s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 712 | ▶ | or do { $warn->($s, 'expected a numeric value'); return 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 374 | ▶ | my $from = $body =~ /^0[xX]/ ? 'from_hex' : $body =~ /^0./ ? 'from_oct' : 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 374 | my $v = Math::BigInt->$from($body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 374 | ▶ | $v->bneg if $sign eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 374 | ▶ | my ($lo, $hi) = $kind eq 'u' ? (-$UMAX, $UMAX) : ($IMIN, $IMAX); # (strtoumax: -N is 2**64 - N) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 374 | ▶ | if ($v < $lo || $v > $hi) { $warn->($s, 'Numerical result out of range'); $v = $kind eq 'u' || $v > 0 ? $hi : $lo } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition83%5/6
$v < $lo or $v > $hi
$kind eq "u" or $v > 0
MC/DC100%2/2
$v < $lo or $v > $hi
$v < $lo
$v > $hi
MC/DC50%1/2
$kind eq "u" or $v > 0
$kind eq "u"
$v > 0
Truth table100%3/3
A or B
A= $v < $loB= $v > $hi
Truth table66%2/3
A or B
A= $kind eq "u"B= $v > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 105 | elsif (length $rest) { $warn->($s, 'value not completely converted') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 374 | ▶ | $v += $UMAX + 1 if $v < 0 && $kind eq 'u'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$v < 0 and $kind eq "u"
MC/DC100%2/2
$v < 0 and $kind eq "u"
$v < 0
$kind eq "u"
Truth table100%3/3
A and B
A= $v < 0B= $kind eq "u"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1140 | "$v" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1140 | my $used; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1140 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1553 | my $took = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1553 | ▶ | while ($fmt =~ /\G(?:([^%\\]+)|\\(0?[0-7]{1,3}|x[0-9A-Fa-f]{0,2}|u[0-9A-Fa-f]{0,4}|U[0-9A-Fa-f]{0,8}|.?)|%(%)|%([bq]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |%([-+ #0'I]*)(\*|[0-9]*)(?:\.(\*|[0-9]*))?[lLhjtz]*(.?))/gcsx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 4908 | my ($text, $e, $pct, $bq, $fl, $w, $p, $cv, $from) = ($1, $2, $3, $4, $5, $6, $7, $8, $-[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4908 | ▶ | if (defined $text) { $out .= $text; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 3464 | ▶ | if (defined $pct) { $out .= '%'; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3461 | ▶ | if (defined $e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 905 | my ($t, $stop, $error) = esc("\\$e", 'fmt', $env); $out .= $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 905 | ▶ | if ($error) { $msg->($error); return $done->(1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 897 | ▶ | return $done->() if $stop; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2556 | ▶ | $cv = $bq, $fl = $w = '' if defined $bq; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2556 | ▶ | if (!defined $bq && ($cv !~ /^[aAcdeEfFgGiosuxX]\z/ || grep(index($NOT{$_} // "", $cv) >= 0, split //, $fl) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%14/14
not defined $bq and !($cv =~ /^[aAcdeEfFgGiosuxX]\z/) || grep(index($NOT{$_} // "", $cv) != -1, split(//, $fl, 0)) || defined $p && $cv eq "c"
not $cv =~ /^[aAcdeEfFgGiosuxX]\z/ or grep index($NOT{$_} // "", $cv) != -1, split(//, $fl, 0) or defined $p and $cv eq "c"
not $cv =~ /^[aAcdeEfFgGiosuxX]\z/ or grep index($NOT{$_} // "", $cv) != -1, split(//, $fl, 0)
$NOT{$_} // ""
defined $p and $cv eq "c"
MC/DC100%5/5
not defined $bq and !($cv =~ /^[aAcdeEfFgGiosuxX]\z/) || grep(index($NOT{$_} // "", $cv) != -1, split(//, $fl, 0)) || defined $p && $cv eq "c"
not defined $bq
not $cv =~ /^[aAcdeEfFgGiosuxX]\z/
grep index($NOT{$_} // "", $cv) != -1, split(//, $fl, 0)
defined $p
$cv eq "c"
MC/DC100%1/1
$NOT{$_} // ""
$NOT{$_}
Truth table100%6/6
not(A) and not(B) or C or D and E
A= not defined $bqB= not $cv =~ /^[aAcdeEfFgGiosuxX]\z/C= grep index($NOT{$_} // "", $cv) != -1, split(//, $fl, 0)D= defined $pE= $cv eq "c"
Truth table100%2/2
A
A= $NOT{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | || defined $p && $cv eq 'c')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 340 | $msg->(substr($fmt, $from, pos($fmt) - $from) . ": invalid conversion specification"); return $done->(1) } # (as written) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2216 | $used = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2216 | ▶ | if ($w eq '*') { $w = 0 + $num->(shift(@a), 'i'); $took++; $fl .= '-', $w = -$w if $w < 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2216 | ▶ | if (defined $p && $p eq '*') { $p = 0 + $num->(shift(@a), 'i'); $took++; undef $p if $p < 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $p and $p eq "*"
MC/DC100%2/2
defined $p and $p eq "*"
defined $p
$p eq "*"
Truth table100%3/3
A and B
A= defined $pB= $p eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2216 | ▶ | my $arg = shift @a; $took++ if defined $arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2216 | $fl =~ tr/'I//d; # (grouping, the locale's digits: none in the C locale) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2216 | ▶ | my $spec = "%$fl$w" . (defined $p ? ".$p" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2216 | ▶ | if ($cv eq 'q') { $out .= shell_quote($arg, $env) if defined $arg } # (no argument: nothing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | elsif ($cv eq 'b') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 21 | ▶ | my ($t, $stop, $error) = esc($arg // '', 'b', $env); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg // ""
MC/DC100%1/1
$arg // ""
$arg
Truth table100%2/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 21 | ▶ | if ($error) { $out .= $t; $msg->($error); return $done->(1) } # what came before the bad escape, as coreutils | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 17 | ▶ | $out .= sprintf "${spec}s", $t; return $done->() if $stop } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 169 | ▶ | elsif ($cv eq 's') { $out .= sprintf "${spec}s", $arg // '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg // ""
MC/DC100%1/1
$arg // ""
$arg
Truth table100%2/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 67 | ▶ | elsif ($cv eq 'c') { my $c = substr $arg // '', 0, 1; $out .= sprintf "${spec}s", length $c ? $c : "\0" } # (none: a NUL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$arg // ""
MC/DC100%1/1
$arg // ""
$arg
Truth table100%2/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 361 | elsif ($cv =~ /[di]/) { $out .= sprintf "${spec}d", $num->($arg, 'i') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 736 | elsif ($cv =~ /[ouxX]/) { $out .= sprintf "$spec$cv", $num->($arg, 'u') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 832 | else { $out .= float($spec, $fl, $w, $p, $cv, $num->($arg, 'f'), $arg) } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1197 | ▶ | last unless @a && $took; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@a and $took
MC/DC100%2/2
@a and $took
@a
$took
Truth table100%3/3
A and B
A= @aB= $took
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 413 | pos $fmt = 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 784 | ▶ | $msg->("warning: ignoring excess arguments, starting with " . q_($env, $a[0])) if @a && !$used; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@a and not $used
MC/DC50%1/2
@a and not $used
@a
not $used
Truth table66%2/3
A and not(B)
A= @aB= not $used
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 784 | $done->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 832 | ▶ | sub float { # a floating conversion: Perl's sprintf, but inf and nan as glibc writes them, and an integer below 2**64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
float: called CC=17 SCAR=28.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 832 | my ($spec, $fl, $w, $p, $cv, $v, $arg) = @_; # under %f exact, as coreutils' long double has it (a double rounds) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 832 | ▶ | my $sign = $fl =~ /\+/ ? '+' : $fl =~ / / ? ' ' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 832 | ▶ | if ($v != $v || abs $v == 9**9**9) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$v != $v or abs $v == "Inf"
MC/DC100%2/2
$v != $v or abs $v == "Inf"
$v != $v
abs $v == "Inf"
Truth table100%3/3
A or B
A= $v != $vB= abs $v == "Inf"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 44 | ▶ | my $t = ($v < 0 ? '-' : $sign) . ($v != $v ? 'nan' : 'inf'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 44 | ▶ | return pad($fl =~ tr/0//dr, $w, $cv =~ /[EFGA]/ ? uc $t : $t) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 788 | ▶ | if ($cv =~ /[fF]/ && defined $arg && $arg =~ /^\s*([-+]?)0*([0-9]{16,20})\s*\z/ && Math::BigInt->new($2) <= $UMAX) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$cv =~ /[fF]/ and defined $arg and $arg =~ /^\s*([-+]?)0*([0-9]{16,20})\s*\z/ and "Math::BigInt"->new($2) <= $UMAX
$cv =~ /[fF]/ and defined $arg and $arg =~ /^\s*([-+]?)0*([0-9]{16,20})\s*\z/
$cv =~ /[fF]/ and defined $arg
MC/DC75%3/4
$cv =~ /[fF]/ and defined $arg and $arg =~ /^\s*([-+]?)0*([0-9]{16,20})\s*\z/ and "Math::BigInt"->new($2) <= $UMAX
$cv =~ /[fF]/
defined $arg
$arg =~ /^\s*([-+]?)0*([0-9]{16,20})\s*\z/
"Math::BigInt"->new($2) <= $UMAX
Truth table80%4/5
A and B and C and D
A= $cv =~ /[fF]/B= defined $argC= $arg =~ /^\s*([-+]?)0*([0-9]{16,20})\s*\z/D= "Math::BigInt"->new($2) <= $UMAX
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 10 | ▶ | my $prec = $p // 6; $prec ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$p // 6
$prec ||= 0
MC/DC100%1/1
$p // 6
$p
MC/DC0%0/1
$prec ||= 0
$prec
Truth table100%2/2
A
A= $p
Truth table50%1/2
A
A= $prec
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 10 | ▶ | return pad($fl, $w, ($1 eq '-' ? '-' : $sign) . $2 . ($prec || $fl =~ /#/ ? '.' . '0' x $prec : '')) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$prec or $fl =~ /#/
MC/DC0%0/2
$prec or $fl =~ /#/
$prec
$fl =~ /#/
Truth table33%1/3
A or B
A= $precB= $fl =~ /#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 778 | sprintf "$spec$cv", $v } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 54 | ▶ | sub pad { my ($fl, $w, $t) = @_; # a number's text in WIDTH, by the flags - and 0 (zeros after the sign) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pad: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 54 | ▶ | my $n = ($w || 0) - length $t; return $t if $n <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$w || 0
MC/DC100%1/1
$w || 0
$w
Truth table100%2/2
A
A= $w
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $fl =~ /-/ ? $t . ' ' x $n : $fl =~ /0/ ? $t =~ s/^([-+ ]?)/$1 . '0' x $n/er : ' ' x $n . $t } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # %q: gnulib's quotearg in shell_escape_quoting_style, as coreutils' printf, with gnulib's later fix (decision IP2): a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # word needing no quotes as it is; else in '...', a ' as '\'', what must be escaped (controls; what the locale cannot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # print, byte by byte in octal) in $'...' runs; a word whose only trouble is a ' (and spaces, #, ~ in front) in "...". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 443 | my %QESC = (%CESC, "\0" => '0'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 26 | ▶ | sub shell_quote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shell_quote: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 26 | ▶ | my ($w, $env) = @_; my $u = is_utf8($env // {}, 'LC_CTYPE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$env // {}
MC/DC0%0/1
$env // {}
$env
Truth table50%1/2
A
A= $env
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 26 | my @c = chars($w, $u); my $plain = !grep !printable($_, $u), @c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 26 | ▶ | return $w if $w ne '' && $plain && $w !~ /[\\?'\s!"\$&()*;<=>\[^`|]|^[#~]|^[{}]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$w ne "" and $plain and not $w =~ /[\\?'\s!"\$&()*;<=>\[^`|]|^[#~]|^[{}]\z/
$w ne "" and $plain
MC/DC100%3/3
$w ne "" and $plain and not $w =~ /[\\?'\s!"\$&()*;<=>\[^`|]|^[#~]|^[{}]\z/
$w ne ""
$plain
not $w =~ /[\\?'\s!"\$&()*;<=>\[^`|]|^[#~]|^[{}]\z/
Truth table100%4/4
A and B and not(C)
A= $w ne ""B= $plainC= not $w =~ /[\\?'\s!"\$&()*;<=>\[^`|]|^[#~]|^[{}]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 17 | ▶ | return qq{"$w"} if $plain && $w =~ /'/ && $w !~ /[\\?!"\$&()*;<=>\[^`|{}]|.[#~]/s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$plain and $w =~ /'/ and not $w =~ /[\\?!"\$&()*;<=>\[^`|{}]|.[#~]/s
$plain and $w =~ /'/
MC/DC66%2/3
$plain and $w =~ /'/ and not $w =~ /[\\?!"\$&()*;<=>\[^`|{}]|.[#~]/s
$plain
$w =~ /'/
not $w =~ /[\\?!"\$&()*;<=>\[^`|{}]|.[#~]/s
Truth table75%3/4
A and B and not(C)
A= $plainB= $w =~ /'/C= not $w =~ /[\\?!"\$&()*;<=>\[^`|{}]|.[#~]/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 15 | my ($q, $dollar) = ("'", 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 15 | for (@c) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 44 | ▶ | if (!printable($_, $u)) { $q .= q{'$'} unless $dollar; $dollar = 1; $q .= c_esc($_, \%QESC) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 4 | elsif ($_ eq "'") { $q .= q{'\''}; $dollar = 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 30 | ▶ | else { $q .= "''" if $dollar; $dollar = 0; $q .= $_ } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 15 | "$q'" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # ------------------------------------------------------------------ test and [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # coreutils' grammar: with 1 to 4 arguments the POSIX rules, else (and inside them where they say so) the expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # -o, -a, !, ( ), -l STRING as an integer. The words are consumed from @W; for [, the ] stays in $BEYOND, past the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # end, where coreutils' messages still see it ("')' expected, found ']'"). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 443 | my %UNARY = map +($_ => 1), qw(-b -c -d -e -f -g -G -h -k -L -N -O -p -r -s -S -t -u -w -x -z -n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 443 | my %BINARY = map +($_ => 1), qw(= == != -eq -ne -lt -le -gt -ge -nt -ot -ef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 443 | our (@W, $LAST, $BEYOND, $CMDENV, $OPT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 881 | ▶ | sub test { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test: called CC=14 SCAR=26.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 881 | my ($argv, $env, $opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 881 | my ($name, @a) = @$argv; my $br = $name =~ m{(?:^|/)\[\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 881 | ▶ | if ($br) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if (my @i = info('[', @a)) { return @i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 296 | ▶ | return ('', "$name: missing " . q_($env // {}, ']') . "\n", 2) unless @a && pop(@a) eq ']' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
@a and pop @a eq "]"
$env // {}
MC/DC50%1/2
@a and pop @a eq "]"
@a
pop @a eq "]"
MC/DC0%0/1
$env // {}
$env
Truth table66%2/3
A and B
A= @aB= pop @a eq "]"
Truth table50%1/2
A
A= $env
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 879 | ▶ | local (@W, $LAST, $BEYOND, $CMDENV, $OPT) = (@a); ($LAST, $BEYOND, $CMDENV, $OPT) = ($a[-1], $br ? ']' : undef, $env // {}, $opt // {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
$env // {}
$opt // {}
MC/DC0%0/1
$env // {}
$env
MC/DC100%1/1
$opt // {}
$opt
Truth table50%1/2
A
A= $env
Truth table100%2/2
A
A= $opt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 879 | ▶ | my $r = eval { my $v = @W ? posix(scalar @W) : 0; die "extra argument " . q_($CMDENV, $W[0]) . "\n" if @W; $v ? 1 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 879 | ▶ | defined $r ? ('', '', $r ? 0 : 1) : ('', "$name: " . $@, 2) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 74 | ▶ | sub beyond { die "missing argument after " . q_($CMDENV, $LAST) . "\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
beyond: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 80 | ▶ | sub next_word { shift @W; beyond() unless @W; 1 } # coreutils' advance(true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_word: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 332 | ▶ | sub dash1 { defined $_[0] && $_[0] =~ /^-.\z/s } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dash1: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 812 | ▶ | sub posix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
posix: called CC=19 SCAR=29.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 812 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 812 | ▶ | if ($n == 1) { return length shift @W } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 690 | ▶ | if ($n == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 152 | ▶ | return !posix(1) if $W[0] eq '!' && shift @W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Proc::ShellSpawn::Programs::W[0] eq "!" and shift @Proc::ShellSpawn::Programs::W
MC/DC50%1/2
$Proc::ShellSpawn::Programs::W[0] eq "!" and shift @Proc::ShellSpawn::Programs::W
$Proc::ShellSpawn::Programs::W[0] eq "!"
shift @Proc::ShellSpawn::Programs::W
Truth table66%2/3
A and B
A= $Proc::ShellSpawn::Programs::W[0] eq "!"B= shift @Proc::ShellSpawn::Programs::W
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 144 | ▶ | return unary_op() if $UNARY{$W[0]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 90 | ▶ | dash1($W[0]) ? die q_($CMDENV, $W[0]) . ": unary operator expected\n" : beyond() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 538 | ▶ | if ($n == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 196 | ▶ | return binary_op(0) if $BINARY{$W[1]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 106 | ▶ | return next_word() && !posix(2) if $W[0] eq '!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
next_word() && !posix(2)
MC/DC0%0/2
next_word() && !posix(2)
next_word()
!posix(2)
Truth table33%1/3
A && not(B)
A= next_word()B= !posix(2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 96 | ▶ | return (shift @W, posix(1), shift @W)[1] if $W[0] eq '(' && $W[2] eq ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Proc::ShellSpawn::Programs::W[0] eq "(" and $Proc::ShellSpawn::Programs::W[2] eq ")"
MC/DC100%2/2
$Proc::ShellSpawn::Programs::W[0] eq "(" and $Proc::ShellSpawn::Programs::W[2] eq ")"
$Proc::ShellSpawn::Programs::W[0] eq "("
$Proc::ShellSpawn::Programs::W[2] eq ")"
Truth table100%3/3
A and B
A= $Proc::ShellSpawn::Programs::W[0] eq "("B= $Proc::ShellSpawn::Programs::W[2] eq ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 94 | ▶ | return expr() if $W[1] =~ /^-[ao]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 80 | die q_($CMDENV, $W[1]) . ": binary operator expected\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 342 | ▶ | if ($n == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 118 | ▶ | return next_word() && !posix(3) if $W[0] eq '!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
next_word() && !posix(3)
MC/DC0%0/2
next_word() && !posix(3)
next_word()
!posix(3)
Truth table33%1/3
A && not(B)
A= next_word()B= !posix(3)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 114 | ▶ | return (shift @W, posix(2), shift @W)[1] if $W[0] eq '(' && $W[3] eq ')' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Proc::ShellSpawn::Programs::W[0] eq "(" and $Proc::ShellSpawn::Programs::W[3] eq ")"
MC/DC0%0/2
$Proc::ShellSpawn::Programs::W[0] eq "(" and $Proc::ShellSpawn::Programs::W[3] eq ")"
$Proc::ShellSpawn::Programs::W[0] eq "("
$Proc::ShellSpawn::Programs::W[3] eq ")"
Truth table66%2/3
A and B
A= $Proc::ShellSpawn::Programs::W[0] eq "("B= $Proc::ShellSpawn::Programs::W[3] eq ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 338 | expr() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 352 | ▶ | sub expr { beyond() unless @W; my $v = and_(); while (@W && $W[0] eq '-o') { shift @W; my $r = and_(); $v ||= $r } $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expr: called CC=5 SCAR=16.2
Pod
undocumented
Branch: 2 branches
Condition83%5/6
@Proc::ShellSpawn::Programs::W and $Proc::ShellSpawn::Programs::W[0] eq "-o"
$v ||= $r
MC/DC100%2/2
@Proc::ShellSpawn::Programs::W and $Proc::ShellSpawn::Programs::W[0] eq "-o"
@Proc::ShellSpawn::Programs::W
$Proc::ShellSpawn::Programs::W[0] eq "-o"
MC/DC50%1/2
$v ||= $r
$v
$r
Truth table100%3/3
A and B
A= @Proc::ShellSpawn::Programs::WB= $Proc::ShellSpawn::Programs::W[0] eq "-o"
Truth table66%2/3
A ||= B
A= $vB= $r
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 372 | ▶ | sub and_ { my $v = term(); while (@W && $W[0] eq '-a') { shift @W; my $r = term(); $v &&= $r } $v } # (every term evaluated) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
and_: called CC=4 SCAR=13.9
Pod
undocumented
Branch: 1 branch
Condition83%5/6
@Proc::ShellSpawn::Programs::W and $Proc::ShellSpawn::Programs::W[0] eq "-a"
$v &&= $r
MC/DC100%2/2
@Proc::ShellSpawn::Programs::W and $Proc::ShellSpawn::Programs::W[0] eq "-a"
@Proc::ShellSpawn::Programs::W
$Proc::ShellSpawn::Programs::W[0] eq "-a"
MC/DC50%1/2
$v &&= $r
$v
$r
Truth table100%3/3
A and B
A= @Proc::ShellSpawn::Programs::WB= $Proc::ShellSpawn::Programs::W[0] eq "-a"
Truth table66%2/3
A &&= B
A= $vB= $r
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 390 | ▶ | sub term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
term: called CC=19 SCAR=29.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 390 | my $neg = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 390 | ▶ | next_word(), $neg = !$neg while @W && $W[0] eq '!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@Proc::ShellSpawn::Programs::W and $Proc::ShellSpawn::Programs::W[0] eq "!"
MC/DC100%2/2
@Proc::ShellSpawn::Programs::W and $Proc::ShellSpawn::Programs::W[0] eq "!"
@Proc::ShellSpawn::Programs::W
$Proc::ShellSpawn::Programs::W[0] eq "!"
Truth table100%3/3
A and B
A= @Proc::ShellSpawn::Programs::WB= $Proc::ShellSpawn::Programs::W[0] eq "!"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 390 | ▶ | beyond() unless @W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 388 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 388 | ▶ | if ($W[0] eq '(') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 48 | next_word(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 46 | ▶ | my ($close) = grep $W[$_] eq ')', 1 .. ($#W < 4 ? $#W : 4); # the POSIX rules up to a ')' at most 4 words on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 46 | ▶ | $v = posix($close // scalar @W); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$close // scalar @Proc::ShellSpawn::Programs::W
MC/DC100%1/1
$close // scalar @Proc::ShellSpawn::Programs::W
$close
Truth table100%2/2
A
A= $close
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 20 | ▶ | my $at = @W ? $W[0] : $BEYOND; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 20 | ▶ | die q_($CMDENV, ')') . " expected" . (defined $at ? ", found " . q_($CMDENV, $at) : '') . "\n" unless defined $at && $at eq ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $at and $at eq ")"
MC/DC100%2/2
defined $at and $at eq ")"
defined $at
$at eq ")"
Truth table100%3/3
A and B
A= defined $atB= $at eq ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 6 | shift @W } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 16 | ▶ | elsif (@W >= 4 && $W[0] eq '-l' && $BINARY{$W[2]}) { shift @W; $v = binary_op(1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
@Proc::ShellSpawn::Programs::W >= 4 and $Proc::ShellSpawn::Programs::W[0] eq "-l" and $BINARY{$Proc::ShellSpawn::Programs::W[2]}
@Proc::ShellSpawn::Programs::W >= 4 and $Proc::ShellSpawn::Programs::W[0] eq "-l"
MC/DC66%2/3
@Proc::ShellSpawn::Programs::W >= 4 and $Proc::ShellSpawn::Programs::W[0] eq "-l" and $BINARY{$Proc::ShellSpawn::Programs::W[2]}
@Proc::ShellSpawn::Programs::W >= 4
$Proc::ShellSpawn::Programs::W[0] eq "-l"
$BINARY{$Proc::ShellSpawn::Programs::W[2]}
Truth table75%3/4
A and B and C
A= @Proc::ShellSpawn::Programs::W >= 4B= $Proc::ShellSpawn::Programs::W[0] eq "-l"C= $BINARY{$Proc::ShellSpawn::Programs::W[2]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 82 | ▶ | elsif (@W >= 3 && $BINARY{$W[1]}) { $v = binary_op(0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
@Proc::ShellSpawn::Programs::W >= 3 and $BINARY{$Proc::ShellSpawn::Programs::W[1]}
MC/DC100%2/2
@Proc::ShellSpawn::Programs::W >= 3 and $BINARY{$Proc::ShellSpawn::Programs::W[1]}
@Proc::ShellSpawn::Programs::W >= 3
$BINARY{$Proc::ShellSpawn::Programs::W[1]}
Truth table100%3/3
A and B
A= @Proc::ShellSpawn::Programs::W >= 3B= $BINARY{$Proc::ShellSpawn::Programs::W[1]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 90 | ▶ | elsif (dash1($W[0])) { die q_($CMDENV, $W[0]) . ": unary operator expected\n" unless $UNARY{$W[0]}; $v = unary_op() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 152 | else { $v = length shift @W } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 242 | ▶ | $neg ? !$v : $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 90 | ▶ | sub unary_op { my $op = shift @W; beyond() unless @W; unary($op, shift @W) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unary_op: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 188 | ▶ | sub binary_op { # L: -l STRING before (already taken); -l STRING after counts for the integer operators only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary_op: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 188 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 188 | my ($x, $op) = splice @W, 0, 2; my $y = shift @W; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 188 | ▶ | my $r = $y eq '-l' && @W ? shift @W : undef; # (coreutils: -l after the operator, with a word after it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$y eq "-l" and @Proc::ShellSpawn::Programs::W
MC/DC100%2/2
$y eq "-l" and @Proc::ShellSpawn::Programs::W
$y eq "-l"
@Proc::ShellSpawn::Programs::W
Truth table100%3/3
A and B
A= $y eq "-l"B= @Proc::ShellSpawn::Programs::W
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 188 | ▶ | if ($op =~ /^-(?:eq|ne|lt|le|gt|ge)\z/) { $x = length $x if $l; $y = length $r if defined $r } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 188 | binary($x, $op, $y) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 152 | ▶ | sub int_of { my $s = shift; # an integer of test: blanks around, a sign, digits (any length) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
int_of: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 152 | ▶ | $s =~ /^[ \t]*([-+]?[0-9]+)[ \t]*\z/ ? Math::BigInt->new($1) : die "invalid integer " . q_($CMDENV, $s) . "\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 76 | ▶ | sub path { my $f = shift; defined $OPT->{cwd} && length $f && !File::Spec->file_name_is_absolute($f) ? "$OPT->{cwd}/$f" : $f } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=4 SCAR=14.2
Pod
undocumented
Branch: 1 branch
Condition66%4/6
defined $Proc::ShellSpawn::Programs::OPT->{"cwd"} and length $f and not "File::Spec"->file_name_is_absolute($f)
defined $Proc::ShellSpawn::Programs::OPT->{"cwd"} and length $f
MC/DC33%1/3
defined $Proc::ShellSpawn::Programs::OPT->{"cwd"} and length $f and not "File::Spec"->file_name_is_absolute($f)
defined $Proc::ShellSpawn::Programs::OPT->{"cwd"}
length $f
not "File::Spec"->file_name_is_absolute($f)
Truth table50%2/4
A and B and not(C)
A= defined $Proc::ShellSpawn::Programs::OPT->{"cwd"}B= length $fC= not "File::Spec"->file_name_is_absolute($f)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 8 | ▶ | sub mtime { my @s = eval { require Time::HiRes; Time::HiRes::stat($_[0]) }; @s = stat $_[0] unless @s; @s ? $s[9] : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mtime: called CC=3 SCAR=11.3
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my %CMP = (eq => sub { $_[0] == 0 }, ne => sub { $_[0] != 0 }, lt => sub { $_[0] < 0 }, le => sub { $_[0] <= 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Subroutine
__ANON__: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 7 | ▶ | gt => sub { $_[0] > 0 }, ge => sub { $_[0] >= 0 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 188 | ▶ | sub binary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary: called CC=9 SCAR=22.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 188 | my ($x, $op, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 188 | ▶ | return $x eq $y if $op eq '=' || $op eq '=='; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$op eq "=" or $op eq "=="
MC/DC50%1/2
$op eq "=" or $op eq "=="
$op eq "="
$op eq "=="
Truth table66%2/3
A or B
A= $op eq "="B= $op eq "=="
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 126 | ▶ | return $x ne $y if $op eq '!='; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 110 | ▶ | return $CMP{$1}->(int_of($x) <=> int_of($y)) if $op =~ /^-(eq|ne|lt|le|gt|ge)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 9 | ($x, $y) = (path($x), path($y)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 9 | ▶ | return files_eq($x, $y) if $op eq '-ef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 4 | ▶ | my ($new, $old) = map mtime($_), $op eq '-nt' ? ($x, $y) : ($y, $x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | ▶ | defined $new && (!defined $old || $new > $old) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $new && (!defined($old) || $new > $old)
not defined $old or $new > $old
MC/DC0%0/3
defined $new && (!defined($old) || $new > $old)
defined $new
not defined $old
$new > $old
Truth table25%1/4
A && not(B) or C
A= defined $newB= not defined $oldC= $new > $old
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 88 | ▶ | sub unary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unary: called CC=9 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 88 | my ($op, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 88 | ▶ | return !length $f if $op eq '-z'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 76 | ▶ | return length $f if $op eq '-n'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 60 | ▶ | if ($op eq '-t') { my $d = int_of($f); return $d >= 0 && ($OPT->{isatty} ? $OPT->{isatty}->("$d") : POSIX::isatty("$d")) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$d >= 0 && ($Proc::ShellSpawn::Programs::OPT->{'isatty'} ? $Proc::ShellSpawn::Programs::OPT->{'isatty'}->("$d") : POSIX::isatty("$d"))
MC/DC0%0/2
$d >= 0 && ($Proc::ShellSpawn::Programs::OPT->{'isatty'} ? $Proc::ShellSpawn::Programs::OPT->{'isatty'}->("$d") : POSIX::isatty("$d"))
$d >= 0
($Proc::ShellSpawn::Programs::OPT->{'isatty'} ? $Proc::ShellSpawn::Programs::OPT->{'isatty'}->("$d") : POSIX::isatty("$d"))
Truth table33%1/3
A && B
A= $d >= 0B= ($Proc::ShellSpawn::Programs::OPT->{'isatty'} ? $Proc::ShellSpawn::Programs::OPT->{'isatty'}->("$d") : POSIX::isatty("$d"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 58 | $f = path($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 58 | ▶ | return -l $f if $op eq '-h' || $op eq '-L'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "-h" or $op eq "-L"
MC/DC100%2/2
$op eq "-h" or $op eq "-L"
$op eq "-h"
$op eq "-L"
Truth table100%3/3
A or B
A= $op eq "-h"B= $op eq "-L"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 54 | ▶ | my @s = stat $f or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | return { -e => 1, -f => -f _, -d => -d _, -b => -b _, -c => -c _, -p => -p _, -S => -S _, -u => -u _, -g => -g _, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | -k => -k _, -s => $s[7] > 0, -O => $s[4] == $>, -G => $s[5] == (split ' ', $))[0], -N => $s[9] > $s[8], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 17 | -r => -r $f, -w => -w $f, -x => -x $f }->{$op} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # ------------------------------------------------------------------ pwd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # As coreutils 9.4: -L, -P, --logical, --physical (abbreviated too), the last counts; options also after operands, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # unless POSIXLY_CORRECT (which also makes -L the default); operands only draw a warning. -L prints PWD from ENV if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # it is absolute, has no . or .. component and is the directory (same device and inode); else, and for -P, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # directory with symbolic links resolved. OPT: { cwd => DIR }, the directory (default: Perl's). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 443 | my @PWDLONG = qw(logical physical help version); # (coreutils' order, for its messages) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 443 | my %PWDLONG = (logical => 'L', physical => 'P', help => 'help', version => 'version'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 28 | ▶ | sub pwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pwd: called CC=23 SCAR=34.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 28 | ▶ | my ($argv, $env, $opt) = @_; $env //= {}; $opt //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$env //= {}
$opt //= {}
MC/DC0%0/1
$env //= {}
$env
MC/DC100%1/1
$opt //= {}
$opt
Truth table50%1/2
A
A= $env
Truth table100%2/2
A
A= $opt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 28 | my ($name, @a) = @$argv; my $posix = defined $env->{POSIXLY_CORRECT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 28 | my ($logical, @ops, $err) = ($posix); my $try = "Try '$name --help' for more information.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 28 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 36 | my $w = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if ($w eq '--') { push @ops, @a; last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 36 | ▶ | if ($w =~ /^--([^=]*)(=?)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | my $arg = $2; my @m = grep /^\Q$1\E/, @PWDLONG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | ▶ | return ('', "$name: option '$w' is ambiguous; possibilities:" . join('', map " '--$_'", @m) . "\n$try", 1) if @m > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | ▶ | @m == 1 or return ('', "$name: unrecognized option '$w'\n$try", 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | ▶ | return ('', "$name: option '--$m[0]' doesn't allow an argument\n$try", 1) if $arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $o = $PWDLONG{$m[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return info('pwd', "--$o") if length $o > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $logical = $o eq 'L'; next } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 35 | ▶ | if ($w =~ /^-(.+)/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 34 | for my $l (split //, $1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 36 | ▶ | $l =~ /^[LP]\z/ or return ('', "$name: invalid option -- '$l'\n$try", 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 35 | $logical = $l eq 'L' } next } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | push @ops, $w; if ($posix) { push @ops, @a; last } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 26 | ▶ | $err = "$name: ignoring non-option arguments\n" if @ops; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 26 | ▶ | my $dir = $opt->{cwd} // '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->{"cwd"} // "."
MC/DC0%0/1
$opt->{"cwd"} // "."
$opt->{"cwd"}
Truth table50%1/2
A
A= $opt->{"cwd"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 26 | my $wd = $env->{PWD}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 26 | ▶ | my $ok = $logical && defined $wd && File::Spec->file_name_is_absolute($wd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%9/12
$logical && defined $wd && 'File::Spec'->file_name_is_absolute($wd) && !(($^O eq 'MSWin32' ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))) && files_eq($wd, $dir)
$logical and defined $wd and "File::Spec"->file_name_is_absolute($wd) and not +($^O eq "MSWin32" ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))
$logical and defined $wd and "File::Spec"->file_name_is_absolute($wd)
$logical and defined $wd
MC/DC40%2/5
$logical && defined $wd && 'File::Spec'->file_name_is_absolute($wd) && !(($^O eq 'MSWin32' ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))) && files_eq($wd, $dir)
$logical
defined $wd
"File::Spec"->file_name_is_absolute($wd)
not +($^O eq "MSWin32" ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))
files_eq($wd, $dir)
Truth table50%3/6
A and B and C and not(D) && E
A= $logicalB= defined $wdC= "File::Spec"->file_name_is_absolute($wd)D= not +($^O eq "MSWin32" ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))E= files_eq($wd, $dir)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | && ($^O eq 'MSWin32' ? $wd =~ s{^[/\\]{2}[^/\\]+}{}r : $wd) !~ m{[/\\]\.\.?(?:[/\\]|\z)} # (a UNC server, as '.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # is no . or ..) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | && files_eq($wd, $dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 26 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 26 | ▶ | (($ok ? $wd : Cwd::abs_path($dir)) . "\n", $err // '', 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$err // ""
MC/DC100%1/1
$err // ""
$err
Truth table100%2/2
A
A= $err
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1808 | ▶ | sub info { # NAME's result when --help or --version is its only argument: (TEXT, '', 0); else nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
info: called CC=4 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1808 | ▶ | my ($n, @a) = @_; @a == 1 && $a[0] =~ /^--(help|version)\z/ or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@a == 1 and $a[0] =~ /^--(help|version)\z/
MC/DC0%0/2
@a == 1 and $a[0] =~ /^--(help|version)\z/
@a == 1
$a[0] =~ /^--(help|version)\z/
Truth table66%2/3
A and B
A= @a == 1B= $a[0] =~ /^--(help|version)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | ($1 eq 'help' ? help($n) : version($n), '', 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | sub help { my $n = shift; "Usage: $n ...\n(in the Perl process: Proc::ShellSpawn::Programs, after GNU coreutils 9.4's $n)\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | sub version { my $n = shift; "$n (Proc::ShellSpawn::Programs $VERSION, after GNU coreutils 9.4)\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 12 | ▶ | sub true { ('', '', 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
true: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 19 | ▶ | sub false { ('', '', 1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
false: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 443 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||