| 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 | 387 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 387 | ▶ | 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 | 387 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 387 | my $IMAX = Math::BigInt->new('9223372036854775807'); my $IMIN = -$IMAX - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 387 | my $UMAX = Math::BigInt->new('18446744073709551615'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 387 | my %CESC = ("\a" => 'a', "\b" => 'b', "\f" => 'f', "\n" => 'n', "\r" => 'r', "\t" => 't', "\013" => 'v'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 387 | 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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 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=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # doubled, control characters as C escapes, what the locale cannot print in octal, and (C locale) \' for ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1305 | my $u = is_utf8($env, 'LC_MESSAGES'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1305 | my $t = join '', map { printable($_, $u) ? ($_ eq '\\' ? '\\\\' : $_ eq "'" && !$u ? "\\'" : $_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4872 | ▶ | : join '', map $CESC{$_} ? "\\$CESC{$_}" : sprintf('\\%03o', ord), split // } chars($s, $u); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1305 | ▶ | $u ? "\xe2\x80\x98$t\xe2\x80\x99" : "'$t'" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # ------------------------------------------------------------------ echo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # OPT's echo (Proc::ShellSpawn: PROC_SHELLSPAWN_ECHO; decision EC1, the user, 2026-11-09) picks whose echo this is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # coreutils (the default): coreutils 9.4's; POSIXLY_CORRECT in ENV changes it (escapes always, options only a first -n) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # dash: dash 0.5.12's builtin: escapes always (not \x), options only a first -n; POSIXLY_CORRECT changes nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # bash: bash 5.2's builtin (xpg_echo off, as bash --posix starts): options -n -e -E, escapes with -e (also \E, \u, \U) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 387 | our @ECHO = qw(coreutils dash bash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1581 | ▶ | sub echo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
echo: called CC=28 SCAR=33.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1581 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1581 | my @a = @$argv[1 .. $#$argv]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1581 | ▶ | my ($nl, $esc, $mode) = (1, 0, $style eq 'coreutils' ? 'echo' : $style); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1581 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 368 | ▶ | elsif ($style eq 'bash') { while (@a && $a[0] =~ /^-([eEn]+)\z/) { shift @a; for (split //, $1) { $_ eq 'n' ? ($nl = 0) : ($esc = $_ eq 'e') } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | elsif ($style eq 'coreutils') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 369 | my $posix = defined $env->{POSIXLY_CORRECT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 369 | $esc = $posix; # POSIXLY_CORRECT: escapes always, options only for a first -n | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 369 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 314 | ▶ | return ($1 eq 'help' ? help('echo') : version('echo'), '', 0) if @a == 1 && $a[0] =~ /^--(help|version)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 314 | ▶ | while (@a && $a[0] =~ /^-([eEn]+)\z/) { shift @a; for (split //, $1) { $_ eq 'n' ? ($nl = 0) : ($esc = $_ eq 'e' || $posix) } } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
@a and $a[0] =~ /^-([eEn]+)\z/
$_ eq 'e' || $posix
MC/DC100%2/2
@a and $a[0] =~ /^-([eEn]+)\z/
@a
$a[0] =~ /^-([eEn]+)\z/
MC/DC100%2/2
$_ eq 'e' || $posix
$_ eq 'e'
$posix
Truth table100%3/3
A and B
A= @aB= $a[0] =~ /^-([eEn]+)\z/
Truth table100%3/3
A || B
A= $_ eq 'e'B= $posix
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | else { die "PROC_SHELLSPAWN_ECHO: '$style' is none of @ECHO\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1581 | my $out = join ' ', @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1581 | ▶ | if ($esc) { ($out, my $stop) = esc($out, $mode, $env); return ($out, '', 0) if $stop } # \c: nothing more, not the newline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1509 | ▶ | ($out . ($nl ? "\n" : ''), '', 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # The backslash escapes of echo -e and printf's %b (MODE 'echo' or 'b'), or of printf's format ('fmt'); of dash's and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # bash's builtin echo (MODE 'dash', 'bash'). Returns (TEXT, STOP, ERROR): STOP after \c, ERROR for printf's "missing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # hexadecimal number" and "invalid universal character name". ENV: the command's environment, for \u and \U (the locale). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 387 | my %SIMPLE = (a => "\a", b => "\b", e => "\e", f => "\f", n => "\n", r => "\r", t => "\t", v => "\013", '\\' => '\\'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1947 | ▶ | sub esc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
esc: called CC=26 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1947 | ▶ | 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'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1947 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | : qr/0([0-7]{0,3})|([1-7][0-7]{0,2})/; # echo, dash and %b: \0NNN or \NNN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1947 | ▶ | while ($s =~ /\G(?:([^\\]+)|\\)/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2663 | ▶ | if (defined $1) { $o .= $1; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1405 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1009 | elsif ($s =~ /\G([abefnrtv\\])/gc) { $o .= $SIMPLE{$1} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 76 | elsif ($s =~ /\Gc/gc) { return ($o, 1) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 26 | ▶ | my ($k, $h) = defined $1 ? ($1, $2) : ($3, $4); my $v = hex $h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 20 | $o .= unichar($v, $env) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 158 | else { $o .= '\\' } # anything else (and a final backslash): the backslash as it is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1859 | ($o, 0) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 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=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # character in UTF-8's old form up to 6 bytes (surrogates too), else the escape \uXXXX or \UXXXXXXXX; above 0x7FFFFFFF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # nothing (checked against bash 5.2.21 in C and C.UTF-8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 22 | my ($v, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 22 | ▶ | return '' if $v > 0x7fffffff; return chr $v if $v < 0x80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 16 | ▶ | return sprintf($v <= 0xffff ? '\\u%04X' : '\\U%08X', $v) unless is_utf8($env, 'LC_CTYPE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 8 | ▶ | my ($n, $lead) = $v < 0x800 ? (2, 0xc0) : $v < 0x10000 ? (3, 0xe0) : $v < 0x200000 ? (4, 0xf0) : $v < 0x4000000 ? (5, 0xf8) : (6, 0xfc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 8 | my @b; for (2 .. $n) { unshift @b, 0x80 | ($v & 0x3f); $v >>= 6 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | pack 'C*', $lead | $v, @b } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # encoded where the locale can (here: a UTF-8 locale), else (the C locale) the escape \uXXXX or \UXXXXXXXX, as above | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # U+10FFFF everywhere. (A legacy locale such as ISO-8859-1, which coreutils would convert to by iconv, gets the escape.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 20 | my ($v, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 20 | ▶ | return chr $v if $v < 0x80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 8 | ▶ | sprintf $v < 0x10000 ? '\u%04X' : '\U%08X', $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # ------------------------------------------------------------------ printf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # with c s, a precision not with c); %b and %q take nothing between % and the letter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 387 | my %NOT = ("'" => 'aAceEosxX', I => 'aAceEosxX', '#' => 'cdisu', 0 => 'cs'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1141 | ▶ | sub printf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printf: called CC=45 SCAR=38.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1141 | ▶ | my ($argv, $env) = @_; $env //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$env //= {}
MC/DC0%0/1
$env //= {}
$env
Truth table50%1/2
A
A= $env
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1141 | my ($name, @a) = @$argv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1141 | ▶ | return ($1 eq 'help' ? help('printf') : version('printf'), '', 0) if @a == 1 && $a[0] =~ /^--(help|version)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1141 | ▶ | 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 "--"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1141 | ▶ | return ('', "$name: missing operand\nTry '$name --help' for more information.\n", 1) unless @a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1139 | my $fmt = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1139 | my ($out, $err, $bad, $flushed, @seq) = ('', '', 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1139 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1139 | ▶ | my $warn = sub { $msg->(q_($env, $_[0]) . ": $_[1]"); $bad = 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1139 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1936 | my ($s, $kind) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 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 ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1314 | ▶ | if ($s =~ /^\s*['"](.)(.*)/s) { # 'c: the character's code (a warning for more, the status kept) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 36 | ▶ | $msg->("warning: $2: character(s) following character constant have been ignored") if length $2; return ord $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1278 | ▶ | if ($kind eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 566 | ▶ | $warn->($s, $left == length $s ? 'expected a numeric value' : 'value not completely converted') if $left; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 566 | ▶ | return $left == length $s ? 0 : $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | my ($sign, $body, $rest) = $s =~ /^\s*([-+]?)(0[xX][0-9A-Fa-f]+|0[0-7]*|[1-9][0-9]*)(.*)\z/s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 712 | ▶ | or do { $warn->($s, 'expected a numeric value'); return 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 374 | ▶ | my $from = $body =~ /^0[xX]/ ? 'from_hex' : $body =~ /^0./ ? 'from_oct' : 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 374 | my $v = Math::BigInt->$from($body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 374 | ▶ | $v->bneg if $sign eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 374 | ▶ | my ($lo, $hi) = $kind eq 'u' ? (-$UMAX, $UMAX) : ($IMIN, $IMAX); # (strtoumax: -N is 2**64 - N) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 105 | elsif (length $rest) { $warn->($s, 'value not completely converted') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1139 | "$v" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1139 | my $used; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1139 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1552 | my $took = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1552 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |%([-+ #0'I]*)(\*|[0-9]*)(?:\.(\*|[0-9]*))?[lLhjtz]*(.?))/gcsx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 4906 | my ($text, $e, $pct, $bq, $fl, $w, $p, $cv, $from) = ($1, $2, $3, $4, $5, $6, $7, $8, $-[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 4906 | ▶ | if (defined $text) { $out .= $text; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3463 | ▶ | if (defined $pct) { $out .= '%'; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3460 | ▶ | if (defined $e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 904 | my ($t, $stop, $error) = esc("\\$e", 'fmt', $env); $out .= $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 904 | ▶ | if ($error) { $msg->($error); return $done->(1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 896 | ▶ | return $done->() if $stop; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2556 | ▶ | $cv = $bq, $fl = $w = '' if defined $bq; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2556 | ▶ | if (!defined $bq && ($cv !~ /^[aAcdeEfFgGiosuxX]\z/ || grep(index($NOT{$_} // "", $cv) >= 0, split //, $fl) || defined $p && $cv eq 'c')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 340 | $msg->(substr($fmt, $from, pos($fmt) - $from) . ": invalid conversion specification"); return $done->(1) } # (as written) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2216 | $used = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2216 | ▶ | if ($w eq '*') { $w = 0 + $num->(shift(@a), 'i'); $took++; $fl .= '-', $w = -$w if $w < 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 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 "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2216 | ▶ | my $arg = shift @a; $took++ if defined $arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2216 | $fl =~ tr/'I//d; # (grouping, the locale's digits: none in the C locale) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2216 | ▶ | my $spec = "%$fl$w" . (defined $p ? ".$p" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2216 | ▶ | if ($cv eq 'q') { $out .= shell_quote($arg, $env) if defined $arg } # (no argument: nothing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | elsif ($cv eq 'b') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 21 | ▶ | if ($error) { $out .= $t; $msg->($error); return $done->(1) } # what came before the bad escape, as coreutils | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 17 | ▶ | $out .= sprintf "${spec}s", $t; return $done->() if $stop } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 361 | elsif ($cv =~ /[di]/) { $out .= sprintf "${spec}d", $num->($arg, 'i') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 736 | elsif ($cv =~ /[ouxX]/) { $out .= sprintf "$spec$cv", $num->($arg, 'u') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 832 | else { $out .= float($spec, $fl, $w, $p, $cv, $num->($arg, 'f'), $arg) } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1196 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 413 | pos $fmt = 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 783 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 783 | $done->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 832 | my ($spec, $fl, $w, $p, $cv, $v, $arg) = @_; # under %f exact, as coreutils' long double has it (a double rounds) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 832 | ▶ | my $sign = $fl =~ /\+/ ? '+' : $fl =~ / / ? ' ' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 44 | ▶ | my $t = ($v < 0 ? '-' : $sign) . ($v != $v ? 'nan' : 'inf'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 44 | ▶ | return pad($fl =~ tr/0//dr, $w, $cv =~ /[EFGA]/ ? uc $t : $t) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 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 =~ /#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 778 | sprintf "$spec$cv", $v } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $fl =~ /-/ ? $t . ' ' x $n : $fl =~ /0/ ? $t =~ s/^([-+ ]?)/$1 . '0' x $n/er : ' ' x $n . $t } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # %q: gnulib's quotearg in shell_escape_quoting_style, as coreutils' printf, with gnulib's later fix (decision IP2): a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # word needing no quotes as it is; else in '...', a ' as '\'', what must be escaped (controls; what the locale cannot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # print, byte by byte in octal) in $'...' runs; a word whose only trouble is a ' (and spaces, #, ~ in front) in "...". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 387 | my %QESC = (%CESC, "\0" => '0'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 26 | ▶ | sub shell_quote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shell_quote: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 26 | my @c = chars($w, $u); my $plain = !grep !printable($_, $u), @c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 15 | my ($q, $dollar) = ("'", 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 15 | for (@c) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 44 | ▶ | if (!printable($_, $u)) { $q .= q{'$'} unless $dollar; $dollar = 1; $q .= join '', map $QESC{$_} ? "\\$QESC{$_}" : sprintf('\\%03o', ord), split // } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | elsif ($_ eq "'") { $q .= q{'\''}; $dollar = 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 30 | ▶ | else { $q .= "''" if $dollar; $dollar = 0; $q .= $_ } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 15 | "$q'" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # ------------------------------------------------------------------ test and [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # coreutils' grammar: with 1 to 4 arguments the POSIX rules, else (and inside them where they say so) the expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # -o, -a, !, ( ), -l STRING as an integer. The words are consumed from @W; for [, the ] stays in $BEYOND, past the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # end, where coreutils' messages still see it ("')' expected, found ']'"). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 387 | 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); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 387 | my %BINARY = map +($_ => 1), qw(= == != -eq -ne -lt -le -gt -ge -nt -ot -ef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 387 | our (@W, $LAST, $BEYOND, $ENV, $OPT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 880 | ▶ | sub test { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test: called CC=16 SCAR=28.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 880 | my ($argv, $env, $opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 880 | my ($name, @a) = @$argv; my $br = $name =~ m{(?:^|/)\[\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 880 | ▶ | if ($br) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 296 | ▶ | return ($1 eq 'help' ? help('[') : version('['), '', 0) if @a == 1 && $a[0] =~ /^--(help|version)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
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/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 878 | ▶ | local (@W, $LAST, $BEYOND, $ENV, $OPT) = (@a); ($LAST, $BEYOND, $ENV, $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 878 | ▶ | my $r = eval { my $v = @W ? posix(scalar @W) : 0; die "extra argument " . q_($ENV, $W[0]) . "\n" if @W; $v ? 1 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 878 | ▶ | defined $r ? ('', '', $r ? 0 : 1) : ('', "$name: " . $@, 2) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 74 | ▶ | sub beyond { die "missing argument after " . q_($ENV, $LAST) . "\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
beyond: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 332 | ▶ | sub dash1 { defined $_[0] && $_[0] =~ /^-.\z/s } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dash1: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 811 | ▶ | sub posix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
posix: called CC=19 SCAR=29.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 811 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 811 | ▶ | if ($n == 1) { return length shift @W } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 689 | ▶ | if ($n == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 144 | ▶ | return unary_op() if $UNARY{$W[0]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 90 | ▶ | dash1($W[0]) ? die q_($ENV, $W[0]) . ": unary operator expected\n" : beyond() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 537 | ▶ | if ($n == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 195 | ▶ | return binary_op(0) if $BINARY{$W[1]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 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 ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 94 | ▶ | return expr() if $W[1] =~ /^-[ao]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 80 | die q_($ENV, $W[1]) . ": binary operator expected\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 342 | ▶ | if ($n == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 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 ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 338 | expr() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 390 | ▶ | sub term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
term: called CC=19 SCAR=29.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 390 | my $neg = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 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 "!"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 390 | ▶ | beyond() unless @W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 388 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 388 | ▶ | if ($W[0] eq '(') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 48 | next_word(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 20 | ▶ | my $at = @W ? $W[0] : $BEYOND; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 20 | ▶ | die q_($ENV, ')') . " expected" . (defined $at ? ", found " . q_($ENV, $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 ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | shift @W } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 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]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 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]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 90 | ▶ | elsif (dash1($W[0])) { die q_($ENV, $W[0]) . ": unary operator expected\n" unless $UNARY{$W[0]}; $v = unary_op() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 152 | else { $v = length shift @W } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 242 | ▶ | $neg ? !$v : $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 187 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 187 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 187 | my ($x, $op) = splice @W, 0, 2; my $y = shift @W; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 187 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 187 | ▶ | if ($op =~ /^-(?:eq|ne|lt|le|gt|ge)\z/) { $x = length $x if $l; $y = length $r if defined $r } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 187 | binary($x, $op, $y) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 152 | ▶ | $s =~ /^[ \t]*([-+]?[0-9]+)[ \t]*\z/ ? Math::BigInt->new($1) : die "invalid integer " . q_($ENV, $s) . "\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 74 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 187 | ▶ | sub binary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary: called CC=12 SCAR=26.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 187 | my ($x, $op, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 187 | ▶ | 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 "=="
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 125 | ▶ | return $x ne $y if $op eq '!='; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 109 | ▶ | return $CMP{$1}->(int_of($x) <=> int_of($y)) if $op =~ /^-(eq|ne|lt|le|gt|ge)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 8 | ($x, $y) = (path($x), path($y)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | ▶ | if ($op eq '-ef') { my @a = stat $x; my @b = stat $y; return @a && @b && $a[0] == $b[0] && $a[1] == $b[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
@a && @b && $a[0] == $b[0] && $a[1] == $b[1]
@a and @b and $a[0] == $b[0]
@a and @b
MC/DC25%1/4
@a && @b && $a[0] == $b[0] && $a[1] == $b[1]
@a
@b
$a[0] == $b[0]
$a[1] == $b[1]
Truth table40%2/5
A and B and C && D
A= @aB= @bC= $a[0] == $b[0]D= $a[1] == $b[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | my ($new, $old) = map mtime($_), $op eq '-nt' ? ($x, $y) : ($y, $x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 88 | ▶ | sub unary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unary: called CC=9 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 88 | my ($op, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 88 | ▶ | return !length $f if $op eq '-z'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 76 | ▶ | return length $f if $op eq '-n'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 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"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 58 | $f = path($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 54 | ▶ | my @s = stat $f or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | return { -e => 1, -f => -f _, -d => -d _, -b => -b _, -c => -c _, -p => -p _, -S => -S _, -u => -u _, -g => -g _, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | -k => -k _, -s => $s[7] > 0, -O => $s[4] == $>, -G => $s[5] == (split ' ', $))[0], -N => $s[9] > $s[8], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 17 | -r => -r $f, -w => -w $f, -x => -x $f }->{$op} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # ------------------------------------------------------------------ pwd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # As coreutils 9.4: -L, -P, --logical, --physical (abbreviated too), the last counts; options also after operands, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # unless POSIXLY_CORRECT (which also makes -L the default); operands only draw a warning. -L prints PWD from ENV if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # it is absolute, has no . or .. component and is the directory (same device and inode); else, and for -P, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # directory with symbolic links resolved. OPT: { cwd => DIR }, the directory (default: Perl's). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 387 | my @PWDLONG = qw(logical physical help version); # (coreutils' order, for its messages) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 387 | my %PWDLONG = (logical => 'L', physical => 'P', help => 'help', version => 'version'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 28 | ▶ | sub pwd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pwd: called CC=27 SCAR=38.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 28 | my ($name, @a) = @$argv; my $posix = defined $env->{POSIXLY_CORRECT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 28 | my ($logical, @ops, $err) = ($posix); my $try = "Try '$name --help' for more information.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 28 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 36 | my $w = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ($w eq '--') { push @ops, @a; last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 36 | ▶ | if ($w =~ /^--([^=]*)(=?)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | my $arg = $2; my @m = grep /^\Q$1\E/, @PWDLONG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | ▶ | return ('', "$name: option '$w' is ambiguous; possibilities:" . join('', map " '--$_'", @m) . "\n$try", 1) if @m > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | @m == 1 or return ('', "$name: unrecognized option '$w'\n$try", 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | return ('', "$name: option '--$m[0]' doesn't allow an argument\n$try", 1) if $arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $o = $PWDLONG{$m[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | return ($o eq 'help' ? help('pwd') : version('pwd'), '', 0) if length $o > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $logical = $o eq 'L'; next } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 35 | ▶ | if ($w =~ /^-(.+)/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 34 | for my $l (split //, $1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 36 | ▶ | $l =~ /^[LP]\z/ or return ('', "$name: invalid option -- '$l'\n$try", 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 35 | $logical = $l eq 'L' } next } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | push @ops, $w; if ($posix) { push @ops, @a; last } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 26 | ▶ | $err = "$name: ignoring non-option arguments\n" if @ops; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 26 | my $wd = $env->{PWD}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | my $ok = $logical && defined $wd && File::Spec->file_name_is_absolute($wd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | && ($^O eq 'MSWin32' ? $wd =~ s{^[/\\]{2}[^/\\]+}{}r : $wd) !~ m{[/\\]\.\.?(?:[/\\]|\z)} # (a UNC server, as '.', is no . or ..) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 26 | ▶ | && do { my @a = stat $wd; my @b = stat $dir; @a && @b && $a[0] == $b[0] && $a[1] == $b[1] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition57%12/21
$logical && defined $wd && 'File::Spec'->file_name_is_absolute($wd) && !(($^O eq 'MSWin32' ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))) && do {
my(@a) = stat $wd;
my(@b) = stat $dir;
@a and @b and $a[0] == $b[0] and $a[1] == $b[1]
}
$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
@a && @b && $a[0] == $b[0] && $a[1] == $b[1]
@a and @b and $a[0] == $b[0]
@a and @b
MC/DC40%2/5
$logical && defined $wd && 'File::Spec'->file_name_is_absolute($wd) && !(($^O eq 'MSWin32' ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))) && do {
my(@a) = stat $wd;
my(@b) = stat $dir;
@a and @b and $a[0] == $b[0] and $a[1] == $b[1]
}
$logical
defined $wd
"File::Spec"->file_name_is_absolute($wd)
not +($^O eq "MSWin32" ? $wd =~ s(^[/\\]{2}[^/\\]+)[]r : $wd) =~ m([/\\]\.\.?(?:[/\\]|\z))
do {
my(@a) = stat $wd;
my(@b) = stat $dir;
@a and @b and $a[0] == $b[0] and $a[1] == $b[1]
}
MC/DC0%0/4
@a && @b && $a[0] == $b[0] && $a[1] == $b[1]
@a
@b
$a[0] == $b[0]
$a[1] == $b[1]
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= do {
my(@a) = stat $wd;
my(@b) = stat $dir;
@a and @b and $a[0] == $b[0] and $a[1] == $b[1]
}
Truth table20%1/5
A and B and C && D
A= @aB= @bC= $a[0] == $b[0]D= $a[1] == $b[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 26 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 9 | ▶ | sub true { ('', '', 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
true: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 19 | ▶ | sub false { ('', '', 1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
false: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 387 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||