line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IPC::ShellCmd::ShBase; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
962
|
use String::ShellQuote qw(shell_quote); |
|
1
|
|
|
|
|
1021
|
|
|
1
|
|
|
|
|
14648
|
|
5
|
1
|
|
|
1
|
|
11
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
393
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
IPC::ShellCmd::ShBase - Base class for shell commands |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package IPC::ShellCmd::Other; |
14
|
|
|
|
|
|
|
use base qw/IPC::ShellCmd::ShBase/; |
15
|
|
|
|
|
|
|
# Note that this is an abstract class.. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Abstract base class for other IPC::ShellCmd command types. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
0
|
|
|
0
|
0
|
|
my $package = shift; |
25
|
0
|
|
|
|
|
|
my %args = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $self = bless { args => \%args }, $package; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub chain { |
33
|
0
|
|
|
0
|
0
|
|
croak "Abstract Class"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub generate_sh_cmd { |
37
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
my $cmd = shift; |
39
|
0
|
|
|
|
|
|
my $args = shift; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $cmd_string = shell_quote(@$cmd); |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if(defined $args->{'-stdin'}) { |
44
|
0
|
|
|
|
|
|
$cmd_string .= ' < ' . shell_quote($args->{'-stdin'}); |
45
|
|
|
|
|
|
|
} |
46
|
0
|
0
|
|
|
|
|
if(defined $args->{'-stdout'}) { |
47
|
0
|
|
|
|
|
|
$cmd_string .= ' > ' . shell_quote($args->{'-stdout'}); |
48
|
|
|
|
|
|
|
} |
49
|
0
|
0
|
|
|
|
|
if(defined $args->{'-stderr'}) { |
50
|
0
|
|
|
|
|
|
$cmd_string .= ' 2> ' . shell_quote($args->{'-stderr'}); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if($args->{'-env'}) { |
54
|
0
|
|
|
|
|
|
for my $k (keys %{$args->{'-env'}}) { |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$cmd_string = $k . "=" . shell_quote($args->{'-env'}->{$k}) . ' ' . |
56
|
|
|
|
|
|
|
$cmd_string; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if(defined $args->{'-umask'}) { |
61
|
0
|
|
|
|
|
|
$cmd_string = sprintf('umask 0%o && %s', $args->{'-umask'}, $cmd_string); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if(defined $args->{'-wd'}) { |
65
|
0
|
|
|
|
|
|
$cmd_string = sprintf('cd %s && %s', shell_quote($args->{'-wd'}), |
66
|
|
|
|
|
|
|
$cmd_string); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $cmd_string; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 BUGS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
I don't know of any, but that doesn't mean they're not there. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHORS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
See L for authors. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 LICENSE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
See L for the license. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |