line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ShellQuote::Any; |
2
|
2
|
|
|
2
|
|
110743
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
2
|
|
|
2
|
|
16
|
my $caller = caller; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
9
|
no strict 'refs'; ## no critic |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
701
|
|
11
|
2
|
|
|
|
|
3
|
*{"${caller}::shell_quote"} = \&shell_quote; |
|
2
|
|
|
|
|
1203
|
|
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub shell_quote { |
15
|
2
|
|
|
2
|
1
|
796
|
my ($cmd, $os) = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
100
|
|
|
|
6
|
if ($os) { |
18
|
1
|
|
|
|
|
4
|
_require($os); |
19
|
1
|
50
|
|
|
|
1138
|
return _is_win32($os) ? _win32_quote($cmd) : _bourne_quote($cmd); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
1
|
|
|
|
|
4
|
_q()->($cmd); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $Q; |
27
|
|
|
|
|
|
|
sub _q { |
28
|
1
|
50
|
|
1
|
|
3
|
return $Q if $Q; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
3
|
_require($^O); |
31
|
|
|
|
|
|
|
|
32
|
1
|
50
|
|
|
|
712
|
if ( _is_win32($^O) ) { |
33
|
0
|
|
|
|
|
0
|
$Q = \&_win32_quote; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
1
|
|
|
|
|
3
|
$Q = \&_bourne_quote; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
6
|
return $Q; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %K; |
43
|
|
|
|
|
|
|
sub _require { |
44
|
2
|
|
|
2
|
|
4
|
my ($os) = @_; |
45
|
|
|
|
|
|
|
|
46
|
2
|
50
|
|
|
|
5
|
return $K{$os} if $K{$os}; |
47
|
|
|
|
|
|
|
|
48
|
2
|
100
|
|
|
|
5
|
my $klass = _is_win32($os) ? 'Win32/ShellQuote.pm' : 'String/ShellQuote.pm'; |
49
|
2
|
|
|
|
|
5
|
$K{$os} = $klass; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
781
|
require "$klass"; ## no critic |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _win32_quote { |
55
|
1
|
|
|
1
|
|
2
|
my ($cmd) = @_; |
56
|
1
|
|
|
|
|
5
|
Win32::ShellQuote::cmd_escape(join ' ', @$cmd); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _bourne_quote { |
60
|
1
|
|
|
1
|
|
2
|
my ($cmd) = @_; |
61
|
1
|
|
|
|
|
3
|
String::ShellQuote::shell_quote(@$cmd); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _is_win32 { |
65
|
4
|
|
|
4
|
|
9
|
my ($os) = @_; |
66
|
|
|
|
|
|
|
|
67
|
4
|
100
|
|
|
|
23
|
return $os =~ m!^(?:MS)?Win(?:32)?$!i ? 1 : 0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |