OpenSSH/ShellQuoter/MSCmd.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 35 CC 3 SCAR 13.9
CC
3
Cov
0%
quote
6.0
shell_fragments
6.0
new
2.0
CRAP 4.0
1 package Net::OpenSSH::ShellQuoter::MSCmd;
2  
3 use strict;
4 use warnings;
5 use Carp;
6  
7 sub new { shift() }
8  
9 sub quote {
10 shift;
11 my $arg = shift;
12 if ($arg =~ /[\r\n\0]/) {
13 croak "can't quote newlines to pass through MS cmd.exe";
14 }
15 $arg =~ s/([()%!^"<>&|])/^$1/g;
16 $arg;
17 }
18  
19 *quote_glob = \&quote;
20  
21 my %fragments = ( stdin_discard => '<NUL:',
22 stdout_discard => '>NUL:',
23 stderr_discard => '2>NUL:',
24 stdout_and_stderr_discard => '>NUL: 2>&1',
25 stderr_to_stdout => '2>&1' );
26  
27 sub shell_fragments {
28 shift;
29 my @f = grep defined, @fragments{@_};
30 wantarray ? @f : join(' ', @f);
31 }
32  
33 1;
34  
35 __END__