| 1 | package Net::OpenSSH::ShellQuoter::POSIX; | ||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||
| 7 | 3 | ▶ | sub new { __PACKAGE__ } | ||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||
| 9 | 1 | my $noquote_class = '.\\w/\\-@,:'; | |||||||||||||||||||||||||
| 10 | 1 | my $glob_class = '*?\\[\\],\\{\\}:!^~'; | |||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||
| 12 | 1827 | ▶ | sub quote { | ||||||||||||||||||||||||
|
Subroutine
quote: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||
| 13 | 1827 | shift; | |||||||||||||||||||||||||
| 14 | my $quoted = join '', | ||||||||||||||||||||||||||
| 15 | 1827 | ▶ | map { ( m|\A'\z| ? "\\'" : | ||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||
| 16 | m|\A'| ? "\"$_\"" : | ||||||||||||||||||||||||||
| 17 | m|\A[$noquote_class]+\z|o ? $_ : | ||||||||||||||||||||||||||
| 18 | "'$_'" ) | ||||||||||||||||||||||||||
| 19 | } split /('+)/, $_[0]; | ||||||||||||||||||||||||||
| 20 | 1827 | ▶ | length $quoted ? $quoted : "''"; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub quote_glob { | ||||||||||||||||||||||||
|
Subroutine
quote_glob: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||
| 25 | 0 | shift; | |||||||||||||||||||||||||
| 26 | 0 | my $arg = shift; | |||||||||||||||||||||||||
| 27 | 0 | my @parts; | |||||||||||||||||||||||||
| 28 | 0 | ▶ | while ((pos $arg ||0) < length $arg) { | ||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
pos $arg || 0
MC/DC0%0/1
pos $arg || 0
pos $arg
Truth table0%0/2
A
A= pos $arg
| |||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($arg =~ m|\G('+)|gc) { | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 30 | 0 | ▶ | push @parts, (length($1) > 1 ? "\"$1\"" : "\\'"); | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||
| 32 | elsif ($arg =~ m|\G([$noquote_class$glob_class]+)|gco) { | ||||||||||||||||||||||||||
| 33 | 0 | push @parts, $1; | |||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||
| 35 | elsif ($arg =~ m|\G(\\[$glob_class\\])|gco) { | ||||||||||||||||||||||||||
| 36 | 0 | push @parts, $1; | |||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||
| 38 | elsif ($arg =~ m|\G\\|gc) { | ||||||||||||||||||||||||||
| 39 | 0 | push @parts, '\\\\' | |||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||
| 41 | elsif ($arg =~ m|\G([^$glob_class\\']+)|gco) { | ||||||||||||||||||||||||||
| 42 | 0 | push @parts, "'$1'"; | |||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||
| 45 | 0 | require Data::Dumper; | |||||||||||||||||||||||||
| 46 | 0 | $arg =~ m|\G(.+)|gc; | |||||||||||||||||||||||||
| 47 | 0 | die "Internal error: unquotable string:\n". Data::Dumper::Dumper($1) ."\n"; | |||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||
| 50 | 0 | my $quoted = join('', @parts); | |||||||||||||||||||||||||
| 51 | 0 | ▶ | length $quoted ? $quoted : "''"; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||
| 54 | 1 | my %fragments = ( stdin_discard => '</dev/null', | |||||||||||||||||||||||||
| 55 | stdout_discard => '>/dev/null', | ||||||||||||||||||||||||||
| 56 | stderr_discard => '2>/dev/null', | ||||||||||||||||||||||||||
| 57 | stdout_and_stderr_discard => '>/dev/null 2>&1', | ||||||||||||||||||||||||||
| 58 | stderr_to_stdout => '2>&1' ); | ||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub shell_fragments { | ||||||||||||||||||||||||
|
Subroutine
shell_fragments: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||
| 61 | 0 | shift; | |||||||||||||||||||||||||
| 62 | 0 | my @f = grep defined, @fragments{@_}; | |||||||||||||||||||||||||
| 63 | 0 | ▶ | wantarray ? @f : join(' ', @f); | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||
| 66 | 1 | 1; | |||||||||||||||||||||||||