| 1 | #!perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | package IPC::Run3::Shell; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # ##### This is the Perl module IPC::Run3::Shell ##### | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Documentation can be found in the file Shell.pod (or via the perldoc command). | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # Copyright (c) 2014 Hauke Daempfling (haukex@zero-g.net). | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # it under the same terms as Perl 5 itself. | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # For more information see the "Perl Artistic License", | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # which should have been distributed with your copy of Perl. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # Try the command "perldoc perlartistic" or see | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # http://perldoc.perl.org/perlartistic.html . | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 17 | our $VERSION = '0.56'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 17 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 17 | ▶ | use warnings::register; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 17 | ▶ | use Scalar::Util qw/ blessed looks_like_number /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 17 | ▶ | use Data::Dumper (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 17 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # debugging stuff | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # either set env var or set this var externally (may set to a fh / glob ref) | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 17 | our $DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 17 | ▶ | BEGIN { $DEBUG = ! ! $ENV{IPC_RUN3_SHELL_DEBUG} unless $DEBUG } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub debug { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | return unless $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=3 SCAR=18.4
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | return print { ref $DEBUG eq 'GLOB' ? $DEBUG : \*STDERR } "# ", __PACKAGE__, " Debug: ", @_, "\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 17 | my $dumper = Data::Dumper->new([])->Terse(1)->Purity(1) | |||||||||||||||||||||||||||||||||||||||||
| 38 | ->Useqq(1)->Quotekeys(0)->Sortkeys(1)->Indent(0)->Pair('=>'); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | ▶ | sub pp { return $dumper->Values(\@_)->Reset->Dump } ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pp: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 17 | ▶ | use IPC::Run3 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 17 | my @RUN3_OPTS = qw/ binmode_stdin binmode_stdout binmode_stderr append_stdout append_stderr return_if_system_error /; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 17 | my %KNOWN_OPTS = map { $_=>1 } @RUN3_OPTS, | |||||||||||||||||||||||||||||||||||||||||
| 45 | qw/ show_cmd allow_exit irs chomp stdin stdout stderr fail_on_stderr both /; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 17 | our $OBJECT_PACKAGE; | |||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | package ## no critic (ProhibitMultiplePackages) | ||||||||||||||||||||||||||||||||||||||||||
| 50 | IPC::Run3::Shell::Autoload; # hide from PAUSE by splitting onto two lines | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 17 | ▶ | BEGIN { $IPC::Run3::Shell::OBJECT_PACKAGE = __PACKAGE__ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 17 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 53 | sub AUTOLOAD { ## no critic (ProhibitAutoloading) | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 14 | ▶ | my $cmd = $AUTOLOAD; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 14 | ▶ | IPC::Run3::Shell::debug "Autoloading '$cmd'" if $IPC::Run3::Shell::DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 14 | $cmd =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 17 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 14 | *$AUTOLOAD = IPC::Run3::Shell::make_cmd($cmd); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 14 | goto &$AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | ▶ | sub DESTROY {} # so AUTOLOAD isn't called on destruction | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 17 | sub new { | |||||||||||||||||||||||||||||||||||||||||
| 65 | 14 | ▶ | my ($class, %opt) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 14 | return bless \%opt, $OBJECT_PACKAGE; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 17 | my %EXPORTABLE = map {$_=>1} qw/ make_cmd /; # "run" gets special handling | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # this run() is for calling via IPC::Run3::Shell::run(), note that we don't export this below | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 17 | *run = make_cmd(); | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | sub import { | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 27 | ▶ | my ($class, @export) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 27 | my ($callpack) = caller; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 27 | return import_into($class, $callpack, @export); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | sub import_into { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 28 | ▶ | my ($class, $callpack, @export) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_into: called CC=18 SCAR=28.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 28 | my %opt; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 28 | ▶ | %opt = ( %opt, %{shift @export} ) while ref $export[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 28 | for my $exp (@export) { | |||||||||||||||||||||||||||||||||||||||||
| 85 | 31 | ▶ | if (!defined $exp) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | warnings::warnif('uninitialized','Use of uninitialized value in import'); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | ▶ | elsif ( !ref($exp) && $exp && ( my ($sym) = $exp=~/^:(\w+)$/ ) ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
not ref $exp and $exp and my($sym) = $exp =~ /^:(\w+)$/
not ref $exp and $exp
MC/DC100%3/3
not ref $exp and $exp and my($sym) = $exp =~ /^:(\w+)$/
not ref $exp
$exp
my($sym) = $exp =~ /^:(\w+)$/
Truth table100%4/4
not(A) and B and C
A= not ref $expB= $expC= my($sym) = $exp =~ /^:(\w+)$/
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 10 | ▶ | if ($sym eq 'run') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | # instead of exporting 'run', we actually export a make_cmd closure (with default options but *no* arguments) | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | debug "Exporting '${callpack}::$sym' => make_cmd("._cmd2str(\%opt).")" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 17 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 5 | *{"${callpack}::$sym"} = make_cmd(\%opt); | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | elsif ($sym eq 'AUTOLOAD') { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | debug "Exporting '${callpack}::$sym'" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 17 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | *{"${callpack}::AUTOLOAD"} = \&{"${OBJECT_PACKAGE}::AUTOLOAD"}; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif ($sym eq 'FATAL') { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | debug "Enabling fatal warnings"; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | warnings->import(FATAL=>'IPC::Run3::Shell'); | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | ▶ | croak "$class can't export \"$sym\"" unless $EXPORTABLE{$sym}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | my $target = __PACKAGE__."::$sym"; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | ▶ | debug "Exporting '${callpack}::$sym' => '$target'" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 17 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | *{"${callpack}::$sym"} = \&{$target}; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 19 | ▶ | my ($sym, @cmd) = ref $exp eq 'ARRAY' ? @$exp : ($exp, $exp); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 19 | ▶ | croak "$class: no function name specified" unless $sym; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 16 | $sym = _strify($sym); # warn on refs | |||||||||||||||||||||||||||||||||||||||||
| 117 | 15 | ▶ | croak "$class: empty command for function \"$sym\"" unless @cmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 14 | ▶ | debug "Exporting '${callpack}::$sym' => make_cmd("._cmd2str(\%opt, @cmd).")" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 17 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 14 | *{"${callpack}::$sym"} = make_cmd(\%opt, @cmd); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 21 | return; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | sub make_cmd { ## no critic (ProhibitExcessComplexity) | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 56 | ▶ | my @omcmd = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_cmd: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 56 | ▶ | warnings::warnif(__PACKAGE__."::make_cmd() may have been called as a method") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$omcmd[0] and $omcmd[0] eq __PACKAGE__
MC/DC100%2/2
$omcmd[0] and $omcmd[0] eq __PACKAGE__
$omcmd[0]
$omcmd[0] eq __PACKAGE__
Truth table100%3/3
A and B
A= $omcmd[0]B= $omcmd[0] eq __PACKAGE__
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | if $omcmd[0] && $omcmd[0] eq __PACKAGE__ ; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 191 | ▶ | my @acmd = @_; # args to this function call | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=65 SCAR=41.7
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 191 | my @mcmd = @omcmd; # copy of args to make_cmd | |||||||||||||||||||||||||||||||||||||||||
| 133 | # if we are a method, get default options from the object | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 191 | ▶ | my %opt = blessed($acmd[0]) && $acmd[0]->isa($OBJECT_PACKAGE) ? %{shift @acmd} : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($acmd[0]) and $acmd[0]->isa($IPC::Run3::Shell::OBJECT_PACKAGE)
MC/DC100%2/2
builtin::blessed($acmd[0]) and $acmd[0]->isa($IPC::Run3::Shell::OBJECT_PACKAGE)
builtin::blessed($acmd[0])
$acmd[0]->isa($IPC::Run3::Shell::OBJECT_PACKAGE)
Truth table100%3/3
A and B
A= builtin::blessed($acmd[0])B= $acmd[0]->isa($IPC::Run3::Shell::OBJECT_PACKAGE)
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | # hashrefs as the first argument of make_cmd and this method override current options | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 191 | ▶ | %opt = ( %opt, %{shift @mcmd} ) while ref $mcmd[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 191 | ▶ | %opt = ( %opt, %{shift @acmd} ) while ref $acmd[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | # now look at the back of @acmd | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 191 | my @tmp_opts; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 191 | ▶ | push @tmp_opts, pop @acmd while ref $acmd[-1] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 191 | ▶ | %opt = ( %opt, %{pop @tmp_opts} ) while @tmp_opts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | # this is for the tests that test the option inheritance mechanism | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 191 | ▶ | if (exists $opt{__TEST_OPT_A} || exists $opt{__TEST_OPT_B}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $opt{"__TEST_OPT_A"} or exists $opt{"__TEST_OPT_B"}
MC/DC100%2/2
exists $opt{"__TEST_OPT_A"} or exists $opt{"__TEST_OPT_B"}
exists $opt{"__TEST_OPT_A"}
exists $opt{"__TEST_OPT_B"}
Truth table100%3/3
A or B
A= exists $opt{"__TEST_OPT_A"}B= exists $opt{"__TEST_OPT_B"}
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | return join ',', ( | ||||||||||||||||||||||||||||||||||||||||||
| 145 | exists $opt{__TEST_OPT_A} ? 'A='.(defined $opt{__TEST_OPT_A} ? $opt{__TEST_OPT_A} : 'undef') : (), | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 45 | ▶ | exists $opt{__TEST_OPT_B} ? 'B='.(defined $opt{__TEST_OPT_B} ? $opt{__TEST_OPT_B} : 'undef') : () ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | # check options for validity | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 146 | for (keys %opt) { | |||||||||||||||||||||||||||||||||||||||||
| 150 | warnings::warnif(__PACKAGE__.": unknown option \"$_\"") | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 113 | ▶ | unless $KNOWN_OPTS{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 145 | ▶ | my $allow_exit = defined $opt{allow_exit} ? $opt{allow_exit} : [0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 145 | ▶ | if ($allow_exit ne 'ANY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 141 | ▶ | $allow_exit = [$allow_exit] unless ref $allow_exit eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 141 | ▶ | warnings::warnif(__PACKAGE__.": allow_exit is empty") unless @$allow_exit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 141 | for (@$allow_exit) { | |||||||||||||||||||||||||||||||||||||||||
| 158 | # We throw our own custom warning instead of Perl's regular warning because Perl's warning | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # would be reported in this module instead of the calling code. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 147 | ▶ | warnings::warnif('numeric','Argument "'.(defined($_)?$_:"(undef)").'" isn\'t numeric in allow_exit') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $_ and &looks_like_number($_)
MC/DC100%2/2
defined $_ and &looks_like_number($_)
defined $_
&looks_like_number($_)
Truth table100%3/3
A and B
A= defined $_B= &looks_like_number($_)
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | unless defined && looks_like_number($_); | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 17 | ▶ | no warnings 'numeric', 'uninitialized'; ## no critic (ProhibitNoWarnings) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 145 | $_ = 0+$_; # so later usage as a number isn't a warning | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # Possible To-Do for Later: Define priorities for incompatible options so we can carp instead of croaking? | ||||||||||||||||||||||||||||||||||||||||||
| 167 | # Also maybe look at some other places where we croak at runtime to see if there is any way to carp there instead. | ||||||||||||||||||||||||||||||||||||||||||
| 168 | croak __PACKAGE__.": can't use options stderr and fail_on_stderr at the same time" | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 143 | ▶ | if exists $opt{stderr} && $opt{fail_on_stderr}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $opt{"stderr"} and $opt{"fail_on_stderr"}
MC/DC100%2/2
exists $opt{"stderr"} and $opt{"fail_on_stderr"}
exists $opt{"stderr"}
$opt{"fail_on_stderr"}
Truth table100%3/3
A and B
A= exists $opt{"stderr"}B= $opt{"fail_on_stderr"}
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | croak __PACKAGE__.": can't use options both and stdout at the same time" | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 142 | ▶ | if $opt{both} && exists $opt{stdout}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opt{"both"} and exists $opt{"stdout"}
MC/DC100%2/2
$opt{"both"} and exists $opt{"stdout"}
$opt{"both"}
exists $opt{"stdout"}
Truth table100%3/3
A and B
A= $opt{"both"}B= exists $opt{"stdout"}
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | croak __PACKAGE__.": can't use options both and stderr at the same time" | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 141 | ▶ | if $opt{both} && exists $opt{stderr}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opt{"both"} and exists $opt{"stderr"}
MC/DC100%2/2
$opt{"both"} and exists $opt{"stderr"}
$opt{"both"}
exists $opt{"stderr"}
Truth table100%3/3
A and B
A= $opt{"both"}B= exists $opt{"stderr"}
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | croak __PACKAGE__.": can't use options both and fail_on_stderr at the same time" | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 140 | ▶ | if $opt{both} && $opt{fail_on_stderr}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opt{"both"} and $opt{"fail_on_stderr"}
MC/DC100%2/2
$opt{"both"} and $opt{"fail_on_stderr"}
$opt{"both"}
$opt{"fail_on_stderr"}
Truth table100%3/3
A and B
A= $opt{"both"}B= $opt{"fail_on_stderr"}
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | # assemble command (after having processed any option hashes etc.) | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 139 | my @fcmd = (@mcmd, @acmd); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 139 | ▶ | croak __PACKAGE__.": empty command" unless @fcmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | # stringify the stringifiable things, handle undef, and warn on refs | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 138 | @fcmd = map {_strify($_)} @fcmd; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | # prepare STDOUT redirection | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 130 | my ($out, $stdout) = (''); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 130 | ▶ | if (exists $opt{stdout}) ## no critic (ProhibitCascadingIfElse) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 18 | { $stdout = $opt{stdout} } | |||||||||||||||||||||||||||||||||||||||||
| 186 | elsif ($opt{both}) | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 9 | ▶ | { $stdout = defined(wantarray) ? \$out : undef } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | elsif (wantarray) | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 10 | { $stdout = $out = [] } | |||||||||||||||||||||||||||||||||||||||||
| 190 | elsif (defined(wantarray)) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 49 | { $stdout = \$out } | |||||||||||||||||||||||||||||||||||||||||
| 192 | else | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 44 | { $stdout = undef } | |||||||||||||||||||||||||||||||||||||||||
| 194 | # prepare STDERR redirection | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 130 | my ($err, $stderr) = (''); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 130 | ▶ | if (exists $opt{stderr}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 6 | { $stderr = $opt{stderr} } | |||||||||||||||||||||||||||||||||||||||||
| 198 | elsif ($opt{fail_on_stderr}) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 9 | { $stderr = \$err } | |||||||||||||||||||||||||||||||||||||||||
| 200 | elsif ($opt{both}) | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 9 | ▶ | { $stderr = wantarray ? \$err : ( defined(wantarray) ? \$out : undef ) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | else | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 106 | { $stderr = undef } | |||||||||||||||||||||||||||||||||||||||||
| 204 | # prepare options hash | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 130 | my %r3o = ( return_if_system_error=>1 ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 130 | ▶ | for (@RUN3_OPTS) { $r3o{$_} = $opt{$_} if exists $opt{$_} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | # execute and process | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 130 | ▶ | debug "run3("._cmd2str(@fcmd).") ".pp(\%opt) if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 130 | ▶ | print { ref $opt{show_cmd} eq 'GLOB' ? $opt{show_cmd} : \*STDERR } '$ '._cmd2str(@fcmd)."\n" if $opt{show_cmd}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 130 | ▶ | local $/ = exists $opt{irs} ? $opt{irs} : $/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | # NOTE that we've documented that the user can rely on $?, so don't mess with it | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 130 | ▶ | IPC::Run3::run3( \@fcmd, $opt{stdin}, $stdout, $stderr, \%r3o ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | or croak __PACKAGE__." (internal): run3 \"$fcmd[0]\" failed"; | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 129 | my $exitcode = $?>>8; | |||||||||||||||||||||||||||||||||||||||||
| 215 | croak "Command \"$fcmd[0]\" failed: process wrote to STDERR: \"$err\"" | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 129 | ▶ | if $opt{fail_on_stderr} && $err ne '' && $err ne $/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$opt{"fail_on_stderr"} and $err ne "" and $err ne $/
$opt{"fail_on_stderr"} and $err ne ""
MC/DC100%3/3
$opt{"fail_on_stderr"} and $err ne "" and $err ne $/
$opt{"fail_on_stderr"}
$err ne ""
$err ne $/
Truth table100%4/4
A and B and C
A= $opt{"fail_on_stderr"}B= $err ne ""C= $err ne $/
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 124 | ▶ | if ($? == -1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | warnings::warnif("Command \"$fcmd[0]\" failed: $!"); | |||||||||||||||||||||||||||||||||||||||||
| 219 | return | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | } | |||||||||||||||||||||||||||||||||||||||||
| 221 | elsif ($?&127) { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | warnings::warnif(sprintf("Command \"%s\" failed: signal %d, %s coredump", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | $fcmd[0], ($?&127), ($?&128)?'with':'without' )) | ||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | # allow_exit is checked for validity above | ||||||||||||||||||||||||||||||||||||||||||
| 227 | warnings::warnif("Command \"$fcmd[0]\" failed: exit status $exitcode") | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 117 | ▶ | unless $allow_exit eq 'ANY' || grep {$_==$exitcode} @$allow_exit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$allow_exit eq "ANY" or grep {$_ == $exitcode;} @$allow_exit
MC/DC100%2/2
$allow_exit eq "ANY" or grep {$_ == $exitcode;} @$allow_exit
$allow_exit eq "ANY"
grep {$_ == $exitcode;} @$allow_exit
Truth table100%3/3
A or B
A= $allow_exit eq "ANY"B= grep {$_ == $exitcode;} @$allow_exit
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 109 | ▶ | return unless defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 77 | ▶ | if (exists $opt{stdout}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 12 | { return $exitcode } | |||||||||||||||||||||||||||||||||||||||||
| 233 | elsif ($opt{both}) { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 8 | ▶ | chomp($out,$err) if $opt{chomp}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 8 | ▶ | return wantarray ? ($out, $err, $exitcode) : $out | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | elsif (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 10 | ▶ | chomp(@$out) if $opt{chomp}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 10 | return @$out | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 47 | ▶ | chomp($out) if $opt{chomp}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 47 | return $out | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 55 | } | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | # This function attempts to behave like normal Perl stringification, but it adds two things: | ||||||||||||||||||||||||||||||||||||||||||
| 249 | # 1. Warnings on undef, in Perl's normal "uninitialized" category, the difference being that | ||||||||||||||||||||||||||||||||||||||||||
| 250 | # with "warnif", they will appear to originate in the calling code, and not in this function. | ||||||||||||||||||||||||||||||||||||||||||
| 251 | # 2. Warn if we are passed a reference that is not an object with overloaded stringification, | ||||||||||||||||||||||||||||||||||||||||||
| 252 | # since that is much more likely to be a mistake on the part of the user instead of intentional. | ||||||||||||||||||||||||||||||||||||||||||
| 253 | sub _strify { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 469 | ▶ | my ($x) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strify: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 469 | ▶ | if (!defined $x) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | warnings::warnif('uninitialized','Use of uninitialized value in argument list'); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | return "" } | |||||||||||||||||||||||||||||||||||||||||
| 258 | ▶ | elsif (blessed($x) && overload::Overloaded($x)) { # an object with overloading | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
builtin::blessed($x) and overload::Overloaded($x)
MC/DC100%2/2
builtin::blessed($x) and overload::Overloaded($x)
builtin::blessed($x)
overload::Overloaded($x)
Truth table100%3/3
A and B
A= builtin::blessed($x)B= overload::Overloaded($x)
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 10 | ▶ | if (overload::Method($x,'""')) # stringification explicitly defined, it'll work | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | { return "$x" } | |||||||||||||||||||||||||||||||||||||||||
| 261 | # Else, stringification is not explicitly defined - stringification *may* work through autogeneration, but it may also die. | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # There doesn't seem to be a way to ask Perl if stringification will die or not other than trying it out with eval. | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # See also: http://www.perlmonks.org/?node_id=1121710 | ||||||||||||||||||||||||||||||||||||||||||
| 264 | # Reminder to self: "$x" will always be defined; even if overloaded stringify returns undef; | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # undef interpolated into the string will cause warning, but the resulting empty string is still defined. | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 5 | elsif (defined(my $rv = eval { "$x" })) | |||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | { return $rv } | |||||||||||||||||||||||||||||||||||||||||
| 268 | elsif ($@=~/\bno method found\b/) { # overloading failed, throw custom error | ||||||||||||||||||||||||||||||||||||||||||
| 269 | # Note: as far as I can tell the message "no method found" | ||||||||||||||||||||||||||||||||||||||||||
| 270 | # hasn't changed since its intoduction in Perl 5.000 | ||||||||||||||||||||||||||||||||||||||||||
| 271 | # (e.g. git log -p -S 'no method found' gv.c ) | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # Perl bug #31793, which relates to overload::StrVal, apparently also caused problems with Carp | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | if (!$overload::VERSION || $overload::VERSION<1.04) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $overload::VERSION or $overload::VERSION < "1.04"
MC/DC0%0/2
not $overload::VERSION or $overload::VERSION < "1.04"
not $overload::VERSION
$overload::VERSION < "1.04"
Truth table33%1/3
not(A) or B
A= not $overload::VERSIONB= $overload::VERSION < "1.04"
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | { die "Package ".ref($x)." doesn't overload stringification: $@" } ## no critic (RequireCarping) | |||||||||||||||||||||||||||||||||||||||||
| 275 | else | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | { croak "Package ".ref($x)." doesn't overload stringification: $@" } | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | # something other than overloading failed, just re-throw | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | else { die $@ } ## no critic (RequireCarping) | |||||||||||||||||||||||||||||||||||||||||
| 280 | # Remember that Perl's normal behavior should stringification not be | ||||||||||||||||||||||||||||||||||||||||||
| 281 | # available is to die; we're just propagating that behavior outward. | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 284 | # Note that objects without any overloading will stringify using Perl's default mechanism | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 455 | ▶ | ref($x) and warnings::warnif(__PACKAGE__.": argument list contains references/objects"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 449 | return "$x" } | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # function for sorta-pretty-printing commands | ||||||||||||||||||||||||||||||||||||||||||
| 290 | sub _cmd2str { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | ▶ | my @c = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cmd2str: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 5 | my $o = ''; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | for my $c (@c) { | |||||||||||||||||||||||||||||||||||||||||
| 294 | 18 | ▶ | $o .= ' ' if $o; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 18 | ▶ | if (ref $c eq 'HASH') { # options | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | # note we don't pay attention to where in the argument list we are | ||||||||||||||||||||||||||||||||||||||||||
| 297 | # (I don't expect hashrefs to appear as arguments, the user is even warned about them) | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $o .= pp($c); | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 18 | ▶ | my $s = defined $c ? "$c" : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 18 | ▶ | $s = pp($s) if $s=~/[^\w\-\=\/\.]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 18 | $o .= $s; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 5 | return $o; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||