OpenSSH/ShellQuoter/Chain.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 43 CC 3 SCAR 13.3
CC
3
Cov
0%
quote_glob
6.0
shell_fragments
6.0
chain
2.0
CRAP 3.8
1 package Net::OpenSSH::ShellQuoter::Chain;
2  
3 use strict;
4 use warnings;
5  
6 use Net::OpenSSH::ShellQuoter;
7  
8 sub chain {
9 my $class = shift;
10 my @quoters = map Net::OpenSSH::ShellQuoter->quoter($_), reverse @_;
11 my $self = \@quoters;
12 bless $self, $class;
13 $self;
14 }
15  
16 sub quote {
17 my ($self, $arg) = @_;
18 $arg = $_->quote($arg) for @$self;
19 $arg;
20 }
21  
22 sub quote_glob {
23 my ($self, $arg) = @_;
24 if (@$self) {
25 $arg = $self->[0]->quote_glob($arg);
26 $arg = $self->[$_]->quote($arg) for 1..$#$self;
27 }
28 $arg
29 }
30  
31 sub shell_fragments {
32 my $self = shift;
33 @$self or return (wantarray ? () : '');
34 $self->[-1]->shell_fragments(@_)
35 }
36  
37  
38 1;