File Coverage

blib/lib/ShellQuote/Any/Tiny.pm
Criterion Covered Total %
statement 13 18 72.2
branch 3 6 50.0
condition 1 3 33.3
subroutine 3 3 100.0
pod 1 1 100.0
total 21 31 67.7


line stmt bran cond sub pod time code
1             package ShellQuote::Any::Tiny;
2              
3             our $DATE = '2017-09-20'; # DATE
4             our $VERSION = '0.007'; # VERSION
5              
6 1     1   53822 use strict;
  1         2  
  1         26  
7             #use warnings;
8              
9 1     1   5 use Exporter qw(import);
  1         1  
  1         219  
10             our @EXPORT_OK = qw(shell_quote);
11             our $OS;
12              
13             sub shell_quote {
14 14     14 1 81592 my $arg = shift;
15              
16 14   33     79 my $os = $OS || $^O;
17              
18 14 50       29 if ($os eq 'MSWin32') {
19 0 0       0 if ($arg =~ /\A\w+\z/) {
20 0         0 return $arg;
21             }
22 0         0 $arg =~ s/\\(?=\\*(?:"|$))/\\\\/g;
23 0         0 $arg =~ s/"/\\"/g;
24 0         0 return qq("$arg");
25             } else {
26 14 100       58 if ($arg =~ /\A\w+\z/) {
27 1         6 return $arg;
28             }
29 13         30 $arg =~ s/'/'"'"'/g;
30 13         41 return "'$arg'";
31             }
32             }
33              
34             1;
35             # ABSTRACT: Escape string for the Unix/Windows shell
36              
37             __END__