line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shell::EnvImporter::Result; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
5
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
222
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
786
|
use Shell::EnvImporter::Change; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Class::MethodMaker 2.0 [ |
10
|
1
|
|
|
|
|
14
|
new => [qw(-hash -init new)], |
11
|
|
|
|
|
|
|
scalar => [qw( |
12
|
|
|
|
|
|
|
shell_status |
13
|
|
|
|
|
|
|
command_status |
14
|
|
|
|
|
|
|
env_status |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
shell_output |
17
|
|
|
|
|
|
|
command_output |
18
|
|
|
|
|
|
|
stderr |
19
|
|
|
|
|
|
|
)], |
20
|
|
|
|
|
|
|
array => [qw( |
21
|
|
|
|
|
|
|
imported |
22
|
|
|
|
|
|
|
)], |
23
|
|
|
|
|
|
|
hash => [qw( |
24
|
|
|
|
|
|
|
start_env |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
changed |
27
|
|
|
|
|
|
|
)], |
28
|
1
|
|
|
1
|
|
6
|
]; |
|
1
|
|
|
|
|
20
|
|
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
512
|
use constant DEFAULTS => ( |
31
|
|
|
|
|
|
|
shell_status => -255, |
32
|
|
|
|
|
|
|
command_status => -255, |
33
|
|
|
|
|
|
|
env_status => -255, |
34
|
1
|
|
|
1
|
|
60942
|
); |
|
1
|
|
|
|
|
3
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
########## |
38
|
|
|
|
|
|
|
sub init { |
39
|
|
|
|
|
|
|
########## |
40
|
15
|
|
|
15
|
0
|
452
|
my $self = shift; |
41
|
15
|
|
|
|
|
37
|
my %args = @_; |
42
|
15
|
|
|
|
|
136
|
my %defaults = (DEFAULTS); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Set supplied fields with defaults |
45
|
15
|
|
|
|
|
53
|
my @fields = (keys %args, keys %defaults); |
46
|
15
|
|
|
|
|
165
|
my %fields; @fields{@fields} = (1) x @fields; |
|
15
|
|
|
|
|
58
|
|
47
|
15
|
|
|
|
|
46
|
@fields = keys %fields; |
48
|
|
|
|
|
|
|
|
49
|
15
|
|
|
|
|
77
|
foreach my $field (@fields) { |
50
|
45
|
50
|
|
|
|
501
|
if ($self->can($field)) { |
51
|
45
|
|
|
|
|
2814
|
my $curval = $self->$field(); |
52
|
45
|
50
|
|
|
|
500
|
my $arg = exists($args{$field}) ? $args{$field} : $defaults{$field}; |
53
|
45
|
50
|
|
|
|
274
|
if (ref($curval) =~ /ARRAY/) { |
|
|
50
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
$self->$field(@$arg); |
55
|
|
|
|
|
|
|
} elsif (ref($curval) =~ /HASH/) { |
56
|
0
|
|
|
|
|
0
|
$self->$field(%$arg); |
57
|
|
|
|
|
|
|
} else { |
58
|
45
|
|
|
|
|
1954
|
$self->$field($arg); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Copy the environment when constructed |
64
|
15
|
|
|
|
|
181
|
$self->_copy_env; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
############ |
71
|
|
|
|
|
|
|
sub failed { |
72
|
|
|
|
|
|
|
############ |
73
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
0
|
|
|
0
|
return $self->shell_status || |
76
|
|
|
|
|
|
|
$self->command_status || |
77
|
|
|
|
|
|
|
$self->env_status; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
############### |
83
|
|
|
|
|
|
|
sub succeeded { |
84
|
|
|
|
|
|
|
############### |
85
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
0
|
|
|
0
|
return $self->shell_status == 0 and |
88
|
|
|
|
|
|
|
$self->command_status == 0 and |
89
|
|
|
|
|
|
|
$self->env_status == 0; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
############################################################################## |
98
|
|
|
|
|
|
|
########################### Private subroutines ############################# |
99
|
|
|
|
|
|
|
############################################################################## |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
############### |
103
|
|
|
|
|
|
|
sub _copy_env { |
104
|
|
|
|
|
|
|
############### |
105
|
15
|
|
|
15
|
|
229
|
my $self = shift; |
106
|
|
|
|
|
|
|
|
107
|
15
|
|
|
|
|
22
|
my %envbak; |
108
|
15
|
|
|
|
|
694
|
@envbak{keys %ENV} = values %ENV; |
109
|
|
|
|
|
|
|
|
110
|
15
|
|
|
|
|
645
|
$self->start_env(%envbak); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__ |