blib/lib/File/Rsync.pm

filter: Statementstmt 39.0% 111 / 284 Branchbran 26.8% 52 / 194 Conditioncond 35.2% 18 / 51 MC/DCmcdc 6.4% 2 / 31 Subroutinesub 68.4% 13 / 19 Podpod 100% 10 / 10 totaltotal 34.9% 206 / 589 SCAR 84.9
CC
129
Cov
34%
getcmd
1977.8
_parseopts
301.8
exec
109.4
CRAP 4866.5
↑ Summary
1 # -*- perl -*-
2 # vim:ft=perl foldlevel=1
3 # __
4 # /\ \ From the mind of
5 # / \ \
6 # / /\ \ \_____ Lee Eakin ( Leakin at dfw dot Nostrum dot com )
7 # / \ \ \______\ or ( Leakin at cpan dot org )
8 # / /\ \ \/____ / or ( Leakin at japh dot net )
9 # \ \ \ \____\/ / or ( Lee at Eakin dot Org )
10 # \ \ \/____ / Wrapper module for the rsync program
11 # \ \____\/ / rsync can be found at http://rsync.samba.org/rsync/
12 # \/______/
13  
14 package File::Rsync;
15 1 require 5.008; # it might work with older versions of 5 but not tested
16  
17 1 ▶use FileHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use IPC::Run3 'run3';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Carp 'carp';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 $VERSION = '0.47';
27  
28 =head1 NAME
29  
30 File::Rsync - perl module interface to rsync(1) F<http://rsync.samba.org/rsync/>
31  
32 =head1 SYNOPSIS
33  
34 use File::Rsync;
35  
36 $obj = File::Rsync->new(
37 archive => 1,
38 compress => 1,
39 rsh => '/usr/local/bin/ssh',
40 'rsync-path' => '/usr/local/bin/rsync'
41 );
42  
43 $obj->exec( src => 'localdir', dest => 'rhost:remotedir' )
44 or warn "rsync failed\n";
45  
46 =head1 DESCRIPTION
47  
48 Perl Convenience wrapper for the rsync(1) program. Written for I<rsync-2.3.2>
49 and updated for I<rsync-3.1.1> but should perform properly with most recent
50 versions.
51  
52 =head2 File::Rsync::new
53  
54 $obj = new File::Rsync;
55  
56 or
57  
58 $obj = File::Rsync->new;
59  
60 or
61  
62 $obj = File::Rsync->new(@options);
63  
64 Create a I<File::Rsync> object.
65 Any options passed at creation are stored in the object as defaults for all
66 future I<exec> calls on that object.
67 Options may be passed in the style of a hash (key/value pairs) and are the
68 same as the long options in I<rsync(1)> without the leading double-hyphen.
69 Any leading single or double-hyphens are removed, and you may use underscore
70 in place of hyphens in option names to simplify quoting and avoid possible
71 equation parsing (subtraction).
72  
73 Although options are key/value pairs, as of version 0.46 the order is now
74 preserved. Passing a hash reference is still supported for backwards
75 compatibility, but is deprecated as order cannot be preserved for this case.
76  
77 An additional option of B<path-to-rsync> also exists which can be used to
78 override the using PATH environemt variable to find the rsync command binary,
79 and B<moddebug> which causes the module methods to print some debugging
80 information to STDERR.
81  
82 There are also 2 options to wrap the source and/or destination paths in
83 double-quotes: these are B<quote-src> and B<quote-dst>, which may be useful
84 in protecting the paths from shell expansion (particularly useful for paths
85 containing spaces). This wraps all source and/or destination paths in
86 double-quotes to limit remote shell expansion. It is similar but not
87 necessarily the same result as the B<protect-args> option in rsync itself.
88  
89 The B<outfun> and B<errfun> options take a function reference, called once
90 for each line of output from the I<rsync> program with the output line passed
91 in as the first argument, the second arg is either 'out' or 'err' depending
92 on the source.
93 This makes it possible to use the same function for both and still determine
94 where the output came from.
95  
96 If options are passed as a hash reference (deprecated), the B<exclude>
97 needs an array reference as it's value since there cannot be duplicate keys
98 in a hash. Since order cannot be preserved in a hash, this module currently
99 limits the use of B<exclude> or B<include> together.
100 They can be mixed together if options are in the form of a list or array ref.
101  
102 Use the '+ ' or '- ' prefix trick to put includes in an B<exclude> array, or
103 to put excludes in an B<include> array (see I<rsync(1)> for details).
104  
105 Include/exclude options form an ordered list.
106 The order must be retained for proper execution.
107 There are also B<source> and B<dest> keys.
108 The key B<src> is also accepted as an equivalent to B<source>, and B<dst> or
109 B<destination> may be used as equivalents to B<dest>.
110 The B<source> option may take a scalar or an array reference.
111 If the source is the local system then multiple B<source> paths are allowed.
112 In this case an array reference should be used.
113 There is also a method for passing multiple source paths to a remote system.
114 This method may be triggered in this module by passing the remote hostname to
115 the B<srchost> key and passing an array reference to the B<source> key.
116 If the source host is being accessed via an Rsync server, the remote hostname
117 should have a single trailing colon on the name.
118 When rsync is called, the B<srchost> value and the values in the B<source>
119 array will be joined with a colon resulting in the double-colon required for
120 server access.
121 The B<dest> key only takes a scalar since I<rsync> only accepts a single
122 destination path.
123  
124 Version 2.6.0 of I<rsync(1)> provides a new B<files-from> option along with
125 a few other supporting options (B<from0>, B<no-relative>, and
126 B<no-implied-dirs>).
127 To support this wonderful new option at the level it deserves, this module
128 now has an additional parameter.
129 As of version 0.46 the value of B<files-from> may be an array reference.
130 The contents of the array are passed to B<files-from> the same as the
131 below method using B<infun> but implemented inside the module.
132  
133 If B<files-from> is set to '-' (meaning read from stdin) you can define
134 B<infun> to be a reference to a function that prints your file list to the
135 default file handle.
136 The output from the function is attached to stdin of the rsync call during
137 exec.
138 If B<infun> is defined it will be called regardless of the value of
139 B<files-from>, so it can provide any data expected on stdin, but keep in mind
140 that stdin will not be attached to a tty so it is not very useful for sending
141 passwords (see the I<rsync(1)> and I<ssh(1)> man pages for ways to handle
142 authentication).
143 The I<rsync(1)> man page has a more complete description of B<files-from>.
144 Also see L<File::Find> for ideas to use with B<files-from> and B<infun>.
145  
146 The B<infun> option may also be used with the B<include-from> or
147 B<exclude-from> options, but this is generally more clumsy than using the
148 B<include> or B<exclude> arrays.
149  
150 Version 2.6.3 of I<rsync(1)> provides new options B<partial-dir>,
151 B<checksum-seed>, B<keep-dirlinks>, B<inplace>, B<ipv4>, and B<ipv6>.
152 Version 2.6.4 of I<rsync(1)> provides new options B<del>, B<delete-before>
153 B<delete-during>, B<delay-updates>, B<dirs>, B<filter>, B<fuzzy>,
154 B<itemize-changes>, B<list-only>, B<omit-dir-times>, B<remove-sent-files>,
155 B<max-size>, and B<protocol>.
156  
157 Version 0.38 of this module also added support for the B<acls> option that
158 is not part of I<rsync(1)> unless the patch has been applied, but people do
159 use it.
160 It also includes a new B<literal> option that takes an array reference
161 similar to B<include>, B<exclude>, and B<filter>.
162 Any arguments in the array are passed as literal arguments to rsync, and are
163 passed first.
164 They should have the proper single or double hyphen prefixes and the elements
165 should be split up the way you want them passed to exec.
166 The purpose of this option is to allow the use of arbitrary options added by
167 patches, and/or to allow the use of new options in rsync without needing an
168 imediate update to the module in addtition to I<rsync(1)> itself.
169  
170 =cut
171  
172 sub new {
173 1 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.1
Pod documented
174  
175 # seed the options hash, booleans, scalars, excludes, source, dest, data,
176 # status, stderr/stdout storage for last exec
177 my $self = {
178 # these are the boolean flags to rsync, all default off, including them
179 # in the args list turns them on
180 flag => {
181 106 map { $_ => 0 }
182 qw(8-bit-output acls append append-verify archive backup
183 blocking-io checksum compress copy-dirlinks copy-links
184 copy-unsafe-links crtimes cvs-exclude daemon del delay-updates
185 delete delete-after delete-before delete-delay delete-during
186 delete-excluded delete-missing-args devices dirs dry-run
187 executability existing fake-super fileflags force force-change
188 force-delete force-schange force-uchange from0 fuzzy group groups
189 hard-links help hfs-compression ignore-errors ignore-existing
190 ignore-missing-args ignore-non-existing ignore-times inc-recursive
191 inplace ipv4 ipv6 keep-dirlinks links list-only msgs2stderr
192 munge-links new-compress no-blocking-io no-detach no-devices
193 no-dirs no-groups no-iconv no-implied-dirs no-inc-recursive
194 no-links no-motd no-owner no-partial no-perms no-progress
195 no-protect-args no-recursive no-relative no-specials no-super
196 no-times no-whole-file numeric-ids old-compress old-dirs
197 omit-dir-times omit-link-times owner partial perms preallocate
198 progress protect-args protect-decmpfs prune-empty-dirs recursive
199 relative remove-source-files safe-links size-only sparse specials
200 stats super times update version whole-file xattrs)
201 },
202 # these have simple scalar args we cannot easily check
203 # use 'string' so I don't forget and leave keyword scalar unqouted
204 string => {
205 39 map { $_ => '' }
206 qw(address backup-dir block-size bwlimit checksum-seed chown
207 compress-level config contimeout csum-length debug files-from
208 groupmap iconv info log-file log-file-format log-format max-delete
209 max-size min-size modify-window only-write-batch out-format outbuf
210 partial-dir password-file port protocol read-batch rsh rsync-path
211 skip-compress sockopts suffix temp-dir timeout usermap
212 write-batch)
213 },
214 # these are not flags but counters, each time they appear it raises the
215 # count, so we keep track and pass them the same number of times
216 counter => {
217 1 map { $_ => 0 }
218 qw(human-readable itemize-changes one-file-system quiet verbose)
219 },
220 # these can be specified multiple times and are additive, the doc also
221 # specifies that it is an ordered list so we must preserve that order
222 list => {
223 'chmod' => [],
224 'compare-dest' => [],
225 'copy-dest' => [],
226 'dparam' => [],
227 'exclude' => [],
228 'exclude-from' => [],
229 'filter' => [],
230 'include' => [],
231 'include-from' => [],
232 'link-dest' => [],
233 'literal' => [],
234 'remote-option' => [],
235 },
236 code => { # input/output user functions
237 'errfun' => undef,
238 'outfun' => undef,
239 # function to prvide --*-from=- data via pipe
240 'infun' => undef,
241 },
242 _perlopts => {
243 # the path name to the rsync binary (default is to use $PATH)
244 'path-to-rsync' => 'rsync',
245 # hostname of source, used if 'source' is an array reference
246 'srchost' => '',
247 # double-quote source and/or destination paths
248 'quote-src' => 0,
249 'quote-dst' => 0,
250 # whether or not to print debug statements
251 'moddebug' => 0,
252 },
253 # source host and/or path names
254 'source' => '',
255 # destination host and/or path
256 'dest' => '',
257 # return status from last exec
258 '_status' => 0,
259 '_realstatus' => 0,
260 # last rsync command-line executed
261 '_lastcmd' => undef,
262 # stderr from last exec in array format (messages from remote rsync proc)
263 '_err' => 0,
264 # stdout from last exec in array format (messages from local rsync proc)
265 '_out' => 0,
266 # this flag changes error checking in 'exec' when called by 'list'
267 '_list_mode' => 0,
268 # this array used to preserve arg order
269 '_args' => [],
270 };
271 1 bless $self, $class; # bless it first so defopts can find out the class
272 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 0 1
273 1 ▶ &defopts($self, @_) or return;
Branch: 1 branch
BranchTrueFalseTotal
&defopts($self, @_) or return 0 1 1
274 }
275 1 return $self;
276 }
277  
278 =head2 File::Rsync::defopts
279  
280 $obj->defopts(@options);
281  
282 or
283  
284 $obj->defopts(\@options);
285  
286 Set default options for future exec calls for the object.
287 See I<rsync(1)> for a complete list of valid options.
288 This is really the internal method that I<new> calls but you can use it too.
289 The B<verbose> and B<quiet> options to rsync are actually counters.
290 When assigning the perl hash-style options you may specify the counter value
291 directly and the module will pass the proper number of options to rsync.
292  
293 =cut
294  
295 sub defopts {
296 # this method has now been split into 2 sub methods (parse and save)
297 # _saveopts and _parseopts should only be used via defopts or exec
298 1 ▶ my $self = shift;
Subroutine defopts: called CC=1 SCAR=0.0
Pod documented
299 1 &_saveopts($self, &_parseopts($self, @_));
300 }
301  
302 sub _parseopts {
303 # this method checks and converts it's args into a reference to a hash
304 # of valid options and returns it to the caller
305 1 ▶ my $self = shift;
Subroutine _parseopts: called CC=36 SCAR=57.1
306 1 my $pkgname = ref $self;
307 1 my $href;
308 1 my %OPT = (); # this is the hash we will return a ref to
309  
310 # make sure we are passed the proper number of args
311 1 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 0 1 1
312 0 ▶ if (my $reftype = ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reftype = ref $_[0]) { } 0 0 0
313 0 ▶ if ($reftype eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($reftype eq 'HASH') { } 0 0 0
elsif ($reftype eq 'ARRAY') { } 0 0 0
314 0 ▶ carp "$pkgname: hash reference is deprecated, use array or list."
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
315 if $^W;
316 0 @_ = %{$_[0]};
317 0 $href++;
318 } elsif ($reftype eq 'ARRAY') {
319 0 @_ = @{$_[0]};
320 } else {
321 0 carp "$pkgname: invalid reference type ($reftype) option.";
322 0 return;
323 }
324 } else {
325 0 carp "$pkgname: invalid option ($_[0]).";
326 0 return;
327 }
328 }
329 1 ▶ if (@_ % 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ % 2) 0 1 1
330 0 carp
331 "$pkgname: invalid number of options passed (must be key/value pairs).";
332 0 return;
333 }
334  
335 # now process the options given, we handle debug first
336 1 ▶ for (my $i = 0; $i < @_; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 3 1 4
337 3 ▶ if ($_[$i] eq 'moddebug') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i] eq "moddebug") 0 3 3
338 0 $OPT{moddebug} = $_[ $i + 1 ];
339 0 ▶ warn "setting debug flag\n" if $OPT{moddebug};
Branch: 1 branch
BranchTrueFalseTotal
if $OPT{"moddebug"} 0 0 0
340 0 last;
341 }
342 }
343  
344 1 my @order;
345 1 ▶ while (my ($inkey, $val) = splice @_, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 3 1 4
346 3 (my $key = $inkey) =~ tr/_/-/;
347 3 $key =~ s/^--?//; # remove any leading hyphens if found
348 3 ▶ $key = 'source' if $key eq 'src';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "src" 1 2 3
349 3 ▶ $key = 'dest' if $key eq 'dst' or $key eq 'destination';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "dst" or $key eq "destination" 0 3 3
Condition33%1/3
$key eq "dst" or $key eq "destination"
l!l&&r!l&&!r
003
MC/DC0%0/2
$key eq "dst" or $key eq "destination"
$key eq "dst" $key eq "destination"
Truth table33%1/3
A or B
A= $key eq "dst"B= $key eq "destination"
ABresult
1X1
011
000
350 3 ▶ next if $key eq 'moddebug'; # we did this one already
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "moddebug" 0 3 3
351 warn "processing option: $inkey\n"
352 if $OPT{moddebug}
353 3 ▶ or $self->{_perlopts}{moddebug};
Branch: 1 branch
BranchTrueFalseTotal
if $OPT{"moddebug"} or $self->{"_perlopts"}{"moddebug"} 0 3 3
Condition33%1/3
$OPT{"moddebug"} or $self->{"_perlopts"}{"moddebug"}
l!l&&r!l&&!r
003
MC/DC0%0/2
$OPT{"moddebug"} or $self->{"_perlopts"}{"moddebug"}
$OPT{"moddebug"} $self->{"_perlopts"}{"moddebug"}
Truth table33%1/3
A or B
A= $OPT{"moddebug"}B= $self->{"_perlopts"}{"moddebug"}
ABresult
1X1
011
000
354 3 ▶ if ( exists $self->{flag}{$key}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"flag"}{$key} or exists $self->{"string"}{$key} or exists $self->{"counter"}{$key} or exists $self->{"_perlopts"}{$key}) 0 2 2
Condition66%6/9
exists $self->{"flag"}{$key} or exists $self->{"string"}{$key} or exists $self->{"counter"}{$key} or exists $self->{"_perlopts"}{$key}
l!l&&r!l&&!r
102
exists $self->{"flag"}{$key} or exists $self->{"string"}{$key} or exists $self->{"counter"}{$key}
l!l&&r!l&&!r
102
exists $self->{"flag"}{$key} or exists $self->{"string"}{$key}
l!l&&r!l&&!r
102
MC/DC25%1/4
exists $self->{"flag"}{$key} or exists $self->{"string"}{$key} or exists $self->{"counter"}{$key} or exists $self->{"_perlopts"}{$key}
exists $self->{"flag"}{$key} exists $self->{"string"}{$key} exists $self->{"counter"}{$key} exists $self->{"_perlopts"}{$key}
Truth table40%2/5
A or B or C or D
A= exists $self->{"flag"}{$key}B= exists $self->{"string"}{$key}C= exists $self->{"counter"}{$key}D= exists $self->{"_perlopts"}{$key}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
355 or exists $self->{string}{$key}
356 or exists $self->{counter}{$key}
357 or exists $self->{_perlopts}{$key})
358 {
359 1 ▶ if ($key eq 'files-from' and ref $val eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'files-from' and ref $val eq 'ARRAY') { } 0 1 1
Condition33%1/3
$key eq "files-from" and ref $val eq "ARRAY"
!ll&&!rl&&r
100
MC/DC0%0/2
$key eq "files-from" and ref $val eq "ARRAY"
$key eq "files-from" ref $val eq "ARRAY"
Truth table33%1/3
A and B
A= $key eq "files-from"B= ref $val eq "ARRAY"
ABresult
0X0
100
111
360 0 push @order, $key, '-', 'infun', $val; # --files-from=- <\@
361 0 $OPT{$key} = '-';
362 0 $OPT{infun} = $val;
363  
364 } else {
365 1 push @order, $key, $val;
366 1 $OPT{$key} = $val;
367 }
368 1 next;
369 }
370 2 ▶ if (exists $self->{list}{$key} or $key eq 'source') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"list"}{$key} or $key eq "source") 1 1 2
Condition66%2/3
exists $self->{"list"}{$key} or $key eq "source"
l!l&&r!l&&!r
011
MC/DC50%1/2
exists $self->{"list"}{$key} or $key eq "source"
exists $self->{"list"}{$key} $key eq "source"
Truth table66%2/3
A or B
A= exists $self->{"list"}{$key}B= $key eq "source"
ABresult
1X1
011
000
371 1 ▶ if (my $reftype = ref $val) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $reftype = ref $val) { } 0 1 1
elsif ($key eq 'source') { } 1 0 1
372 0 ▶ if ($reftype eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if ($reftype eq 'ARRAY') { } 0 0 0
elsif ($key eq 'source' and builtin::blessed($val)) { } 0 0 0
373 0 push @order, $key, $val;
374 0 $OPT{$key} = $val;
375 0 next;
376 ▶ } elsif ($key eq 'source' && blessed $val) {
Condition0%0/3
$key eq "source" and builtin::blessed($val)
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "source" and builtin::blessed($val)
$key eq "source" builtin::blessed($val)
Truth table0%0/3
A and B
A= $key eq "source"B= builtin::blessed($val)
ABresult
0X0
100
111
377 # if it's blessed, assume it returns a string
378 0 $val = [$val];
379 0 push @order, $key, $val;
380 0 $OPT{$key} = $val;
381 0 next;
382 } else {
383 0 carp "$pkgname: invalid reference type for $inkey option.";
384 0 return;
385 }
386 } elsif ($key eq 'source') {
387 1 $val = [$val];
388 1 push @order, $key, $val;
389 1 $OPT{$key} = $val;
390 1 next;
391 } else {
392 0 carp "$pkgname: $inkey value is not a reference.";
393 0 return;
394 }
395 }
396 1 ▶ if ($key eq 'dest') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "dest") 1 0 1
397 1 push @order, $key, $val;
398 1 $OPT{$key} = $val;
399 1 next;
400 }
401 0 ▶ if (exists $self->{code}{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"code"}{$key}) 0 0 0
402 0 ▶ if (ref $val eq 'CODE') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $val eq 'CODE') { } 0 0 0
elsif ($key eq 'infun' and ref $val eq 'ARRAY') { } 0 0 0
403 0 push @order, $key, $val;
404 0 $OPT{$key} = $val;
405 0 next;
406 ▶ } elsif ($key eq 'infun' and ref $val eq 'ARRAY') {
Condition0%0/3
$key eq "infun" and ref $val eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "infun" and ref $val eq "ARRAY"
$key eq "infun" ref $val eq "ARRAY"
Truth table0%0/3
A and B
A= $key eq "infun"B= ref $val eq "ARRAY"
ABresult
0X0
100
111
407 # IPC::Run3 lets us pass an array ref as stdin :)
408 0 push @order, $key, $val;
409 0 $OPT{$key} = $val;
410 0 next;
411 } else {
412 0 carp "$pkgname: $inkey option is not a function reference.";
413 0 return;
414 }
415 }
416  
417 0 carp "$pkgname: $inkey - unknown option.";
418 0 return;
419 }
420 1 ▶ $OPT{_args} = \@order unless $href;
Branch: 1 branch
BranchTrueFalseTotal
unless $href 1 0 1
421 1 return \%OPT;
422 }
423  
424 sub _saveopts {
425 # save the data from the hash passed in the object
426 1 ▶ my $self = shift;
Subroutine _saveopts: called CC=8 SCAR=21.3
427 1 my $pkgname = ref $self;
428 1 my $opts = shift;
429 1 ▶ return unless ref $opts eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $opts eq "HASH" 0 1 1
430 1 SO: for my $opt (keys %$opts) {
431 4 for my $type (qw(flag string counter list code _perlopts)) {
432 19 ▶ if (exists $self->{$type}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$type}{$opt}) 1 18 19
433 1 $self->{$type}{$opt} = $opts->{$opt};
434 1 next SO;
435 }
436 }
437 3 ▶ if ( $opt eq 'source'
Branch: 1 branch
BranchTrueFalseTotal
if ($opt eq 'source' or $opt eq 'dest' or $opt eq '_args') { } 3 0 3
Condition83%5/6
$opt eq "source" or $opt eq "dest" or $opt eq "_args"
l!l&&r!l&&!r
210
$opt eq "source" or $opt eq "dest"
l!l&&r!l&&!r
111
MC/DC0%0/3
$opt eq "source" or $opt eq "dest" or $opt eq "_args"
$opt eq "source" $opt eq "dest" $opt eq "_args"
Truth table75%3/4
A or B or C
A= $opt eq "source"B= $opt eq "dest"C= $opt eq "_args"
ABCresult
1XX1
01X1
0011
0000
438 or $opt eq 'dest'
439 or $opt eq '_args')
440 {
441 3 $self->{$opt} = $opts->{$opt};
442 } else {
443 0 carp "$pkgname: unknown option: $opt.";
444 0 return;
445 }
446 } # end SO
447 1 return 1;
448 }
449  
450 =head2 File::Rsync::getcmd
451  
452 my $cmd = $obj->getcmd(@options);
453  
454 or
455  
456 my $cmd = $obj->getcmd(\@options);
457  
458 or
459  
460 my ($cmd, $infun, $outfun, $errfun, $debug) = $obj->getcmd(\@options);
461  
462 I<getcmd> returns a reference to an array containing the real rsync command
463 that would be called if the exec function were called.
464 The last example above includes a reference to the optional stdin function,
465 stdout function, stderr function, and the debug setting.
466 This is the form used by the I<exec> method to get the extra parameters it
467 needs to do its job.
468 The function is exposed to allow a user-defined exec function to be used, or
469 for debugging purposes.
470  
471 =cut
472  
473 sub getcmd {
474 2 ▶ my $self = shift;
Subroutine getcmd: called CC=65 SCAR=75.9
Pod documented
475 2 my $pkgname = ref $self;
476 2 my $merged = $self;
477 2 my $list = $self->{_list_mode};
478 2 $self->{_list_mode} = 0;
479 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
480 # If args are passed to exec then we have to merge the saved
481 # (default) options with those passed, for any conflicts those passed
482 # directly to exec take precidence
483 0 my $execopts = &_parseopts($self, @_);
484 0 ▶ return unless ref $execopts eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $execopts eq "HASH" 0 0 0
485 0 my %runopts = ();
486 # first copy the default info from $self
487 0 for my $type (qw(flag string counter list code _perlopts)) {
488 0 for my $opt (keys %{$self->{$type}}) {
489 0 $runopts{$type}{$opt} = $self->{$type}{$opt};
490 }
491 }
492 0 for my $opt (qw(source dest)) {
493 0 $runopts{$opt} = $self->{$opt};
494 }
495 0 @{$runopts{_args}} = @{$self->{_args}};
496 # now allow any args passed directly to exec to override
497 0 OPT: for my $opt (keys %$execopts) {
498 0 for my $type (qw(flag string counter list code _perlopts)) {
499 0 ▶ if (exists $runopts{$type}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $runopts{$type}{$opt}) 0 0 0
500 0 $runopts{$type}{$opt} = $execopts->{$opt};
501 0 next OPT;
502 }
503 }
504 0 ▶ if ($opt eq '_args') {
Branch: 2 branches
BranchTrueFalseTotal
if ($opt eq '_args') { } 0 0 0
elsif ($opt eq 'source' or $opt eq 'dest') { } 0 0 0
505 # only preserve order if we already have order
506 0 push @{$runopts{$opt}}, @{$execopts->{$opt}}
507 0 ▶ if @{$runopts{$opt}};
Branch: 1 branch
BranchTrueFalseTotal
if @{$runopts{$opt};} 0 0 0
508 ▶ } elsif ($opt eq 'source' or $opt eq 'dest') {
Condition0%0/3
$opt eq "source" or $opt eq "dest"
l!l&&r!l&&!r
000
MC/DC0%0/2
$opt eq "source" or $opt eq "dest"
$opt eq "source" $opt eq "dest"
Truth table0%0/3
A or B
A= $opt eq "source"B= $opt eq "dest"
ABresult
1X1
011
000
509 0 $runopts{$opt} = $execopts->{$opt};
510 } else {
511 0 carp "$pkgname: unknown option: $opt.";
512 0 return;
513 }
514 }
515 0 $merged = \%runopts;
516 }
517  
518 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not @{$merged->{"_args"};} and (@{$merged->{"list"}{"exclude"};} != 0) + (@{$merged->{"list"}{"include"};} != 0) + (@{$merged->{"list"}{"filter"};} != 0) > 1) 0 2 2
Condition33%1/3
not @{$merged->{"_args"};} and (@{$merged->{"list"}{"exclude"};} != 0) + (@{$merged->{"list"}{"include"};} != 0) + (@{$merged->{"list"}{"filter"};} != 0) > 1
!ll&&!rl&&r
200
MC/DC0%0/2
not @{$merged->{"_args"};} and (@{$merged->{"list"}{"exclude"};} != 0) + (@{$merged->{"list"}{"include"};} != 0) + (@{$merged->{"list"}{"filter"};} != 0) > 1
not @{$merged->{"_args"};} (@{$merged->{"list"}{"exclude"};} != 0) + (@{$merged->{"list"}{"include"};} != 0) + (@{$merged->{"list"}{"filter"};} != 0) > 1
Truth table33%1/3
not(A) and B
A= not @{$merged->{"_args"};}B= (@{$merged->{"list"}{"exclude"};} != 0) + (@{$merged->{"list"}{"include"};} != 0) + (@{$merged->{"list"}{"filter"};} != 0) > 1
ABresult
0X0
100
111
519 2 !@{$merged->{_args}} # include and exclude allowed if ordered args
520 0 && ( (@{$merged->{list}{exclude}} != 0)
521 0 + (@{$merged->{list}{include}} != 0)
522 0 + (@{$merged->{list}{filter}} != 0) > 1)
523 )
524 {
525 0 carp "$pkgname: 'exclude' and/or 'include' and/or 'filter' "
526 . "options specified, only one allowed.";
527 0 return;
528 }
529  
530 2 my $srchost = $merged->{srchost};
531 2 ▶ $srchost .= ':' if $srchost and substr($srchost, 0, 8) ne 'rsync://';
Branch: 1 branch
BranchTrueFalseTotal
if $srchost and substr($srchost, 0, 8) ne "rsync://" 0 2 2
Condition33%1/3
$srchost and substr($srchost, 0, 8) ne "rsync://"
!ll&&!rl&&r
200
MC/DC0%0/2
$srchost and substr($srchost, 0, 8) ne "rsync://"
$srchost substr($srchost, 0, 8) ne "rsync://"
Truth table33%1/3
A and B
A= $srchostB= substr($srchost, 0, 8) ne "rsync://"
ABresult
0X0
100
111
532  
533 # build the real command
534 2 my @cmd = ($merged->{_perlopts}{'path-to-rsync'});
535  
536 2 ▶ if (@{$merged->{_args}}) { # prefer ordered args if we have them
Branch: 1 branch
BranchTrueFalseTotal
if (@{$merged->{'_args'};}) { } 2 0 2
537 2 my $gotsrc;
538 2 ▶ for (my $e = 0; $e < @{$merged->{_args}}; $e += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e < @{$merged->{"_args"};}) 6 2 8
539 6 my $key = $merged->{_args}[$e];
540 6 my $val = $merged->{_args}[ $e + 1 ];
541 6 ▶ if ($key eq 'literal') {
Branch: 7 branches
BranchTrueFalseTotal
if ($key eq 'literal') { } 0 6 6
elsif (exists $merged->{'flag'}{$key}) { } 2 4 6
elsif (exists $merged->{'string'}{$key}) { } 0 4 4
elsif (exists $merged->{'counter'}{$key}) { } 0 4 4
elsif (exists $merged->{'list'}{$key}) { } 0 4 4
elsif ($key eq 'source') { } 2 2 4
elsif ($key eq 'dest') { } 2 0 2
542 0 ▶ push @cmd, ref $val eq 'ARRAY' ? @$val : $val;
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq 'ARRAY' ? : 0 0 0
543 } elsif (exists $merged->{flag}{$key}) {
544 2 ▶ push @cmd, "--$key" if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 2 0 2
545 } elsif (exists $merged->{string}{$key}) {
546 0 ▶ push @cmd, "--$key=$val" if $val;
Branch: 1 branch
BranchTrueFalseTotal
if $val 0 0 0
547 } elsif (exists $merged->{counter}{$key}) {
548 0 ▶ for (my $i = 0; $i < $val; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $val) 0 0 0
549 0 push @cmd, "--$key";
550 }
551 } elsif (exists $merged->{list}{$key}) {
552 0 ▶ push @cmd, ref $val eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq 'ARRAY' ? : 0 0 0
553 ? map "--$key=$_", @$val
554 : "--$key=$val";
555 } elsif ($key eq 'source') {
556 2 ▶ if ($merged->{srchost}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($merged->{'srchost'}) { } 0 2 2
557 push @cmd, $srchost . join ' ',
558 0 ▶ $merged->{'quote-src'}
Branch: 3 branches
BranchTrueFalseTotal
$merged->{'quote-src'} ? : 0 0 0
ref $val eq 'ARRAY' ? : 0 0 0
ref $val eq 'ARRAY' ? : 0 0 0
559 ? map ("\"$_\"", ref $val eq 'ARRAY' ? @$val : $val)
560 : ref $val eq 'ARRAY' ? @$val
561 : $val;
562 } else {
563 push @cmd,
564 2 ▶ $merged->{'quote-src'}
Branch: 3 branches
BranchTrueFalseTotal
$merged->{'quote-src'} ? : 0 2 2
ref $val eq 'ARRAY' ? : 0 0 0
ref $val eq 'ARRAY' ? : 2 0 2
565 ? map ("\"$_\"", ref $val eq 'ARRAY' ? @$val : $val)
566 : ref $val eq 'ARRAY' ? @$val
567 : $val;
568 }
569 2 $gotsrc++;
570 } elsif ($key eq 'dest') {
571 2 ▶ if ($list) {
Branch: 2 branches
BranchTrueFalseTotal
if ($list) { } 0 2 2
elsif (not $gotsrc) { } 0 2 2
572 0 ▶ if (not $gotsrc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($gotsrc) 0 0 0
573 0 ▶ if ($merged->{srchost}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($merged->{'srchost'}) { } 0 0 0
574 0 push @cmd, $srchost;
575 } else {
576 0 carp "$pkgname: no 'source' specified.";
577 0 return;
578 }
579 }
580 } elsif (not $gotsrc) {
581 0 carp
582 "$pkgname: option 'dest' specified without 'source' option.";
583 0 return;
584 } else {
585 2 ▶ push @cmd, $merged->{'quote-dst'} ? "\"$val\"" : $val;
Branch: 1 branch
BranchTrueFalseTotal
$merged->{'quote-dst'} ? : 0 2 2
586 }
587 }
588 }
589 } else {
590 # we do a bunch of extra work here to support hash refs,
591 # they don't work well here, no order, we do what we can
592 # put any literal options first
593 0 ▶ push @cmd, @{$merged->{list}{literal}} if @{$merged->{list}{literal}};
Branch: 1 branch
BranchTrueFalseTotal
if @{$merged->{"list"}{"literal"};} 0 0 0
594  
595 0 for my $opt (sort keys %{$merged->{flag}}) {
596 0 ▶ push @cmd, "--$opt" if $merged->{flag}{$opt};
Branch: 1 branch
BranchTrueFalseTotal
if $merged->{"flag"}{$opt} 0 0 0
597 }
598 0 for my $opt (sort keys %{$merged->{string}}) {
599 push @cmd, "--$opt=$merged->{string}{$opt}"
600 0 ▶ if $merged->{string}{$opt};
Branch: 1 branch
BranchTrueFalseTotal
if $merged->{"string"}{$opt} 0 0 0
601 }
602 0 for my $opt (sort keys %{$merged->{counter}}) {
603 0 ▶ for (my $i = 0; $i < $merged->{counter}{$opt}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $merged->{"counter"}{$opt}) 0 0 0
604 0 push @cmd, "--$opt";
605 }
606 }
607 0 for my $opt (sort keys %{$merged->{list}}) {
608 0 ▶ next if $opt eq 'literal';
Branch: 1 branch
BranchTrueFalseTotal
if $opt eq "literal" 0 0 0
609 0 for my $val (@{$merged->{$opt}}) {
610 0 push @cmd, "--$opt=$val";
611 }
612 }
613  
614 0 ▶ if ($merged->{source}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($merged->{'source'}) { } 0 0 0
elsif ($merged->{'srchost'} and $list) { } 0 0 0
615 0 ▶ if ($merged->{srchost}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($merged->{'srchost'}) { } 0 0 0
616 push @cmd, $srchost . join ' ',
617 $merged->{'quote-src'}
618 0 ? map { "\"$_\"" } @{$merged->{source}}
619 0 ▶ : @{$merged->{source}};
Branch: 1 branch
BranchTrueFalseTotal
$merged->{'quote-src'} ? : 0 0 0
620 } else {
621 push @cmd,
622 $merged->{'quote-src'}
623 0 ? map { "\"$_\"" } @{$merged->{source}}
624 0 ▶ : @{$merged->{source}};
Branch: 1 branch
BranchTrueFalseTotal
$merged->{'quote-src'} ? : 0 0 0
625 }
626 ▶ } elsif ($merged->{srchost} and $list) {
Condition0%0/3
$merged->{"srchost"} and $list
!ll&&!rl&&r
000
MC/DC0%0/2
$merged->{"srchost"} and $list
$merged->{"srchost"} $list
Truth table0%0/3
A and B
A= $merged->{"srchost"}B= $list
ABresult
0X0
100
111
627 0 push @cmd, $srchost;
628 } else {
629 0 ▶ if ($list) {
Branch: 2 branches
BranchTrueFalseTotal
if ($list) { } 0 0 0
elsif ($merged->{'dest'}) { } 0 0 0
630 0 carp "$pkgname: no 'source' specified.";
631 0 return;
632 } elsif ($merged->{dest}) {
633 0 carp "$pkgname: option 'dest' specified without 'source' option.";
634 0 return;
635 } else {
636 0 carp "$pkgname: no source or destination specified.";
637 0 return;
638 }
639 }
640 0 ▶ unless ($list) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($list) 0 0 0
641 0 ▶ if ($merged->{dest}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($merged->{'dest'}) { } 0 0 0
642 push @cmd, $merged->{'quote-dst'}
643 ? "\"$merged->{dest}\""
644 0 ▶ : $merged->{dest};
Branch: 1 branch
BranchTrueFalseTotal
$merged->{'quote-dst'} ? : 0 0 0
645 } else {
646 0 carp "$pkgname: option 'source' specified without 'dest' option.";
647 0 return;
648 }
649 }
650 }
651  
652 return (
653 wantarray
654 ? (\@cmd, $merged->{code}{infun},
655 $merged->{code}{outfun}, $merged->{code}{errfun},
656 $merged->{_perlopts}{moddebug}
657 )
658 2 ▶ : \@cmd
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
659 );
660 }
661  
662 =head2 File::Rsync::exec
663  
664 $obj->exec(@options) or warn "rsync failed\n";
665  
666 or
667  
668 $obj->exec(\@options) or warn "rsync failed\n";
669  
670 This is the method that does the real work.
671 Any options passed to this routine are appended to any pre-set options and
672 are not saved.
673 They effect the current execution of I<rsync> only.
674 In the case of conflicts, the options passed directly to I<exec> take
675 precedence.
676 It returns B<1> if the return status was zero (or true), if the I<rsync>
677 return status was non-zero it returns B<0> and stores the return status.
678 You can examine the return status from I<rsync> and any output to stdout and
679 stderr with the methods listed below.
680  
681 =cut
682  
683 sub exec {
684 1 ▶ my $self = shift;
Subroutine exec: called CC=13 SCAR=46.9
Pod documented
685  
686 1 my ($cmd, $infun, $outfun, $errfun, $debug) = $self->getcmd(@_);
687 1 ▶ return unless $cmd;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmd 0 1 1
688 1 ▶ warn "exec: @$cmd\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
689 1 run3($cmd, $infun, \my $stdout, \my $stderr);
690 0 $self->{_lastcmd} = $cmd;
691 0 $self->{_realstatus} = $?;
692 0 ▶ $self->{_status} = $? & 127 ? $? & 127 : $? >> 8;
Branch: 1 branch
BranchTrueFalseTotal
$? & 127 ? : 0 0 0
693 0 ▶ $self->{_out} = $stdout ? [ split /^/m, $stdout ] : '';
Branch: 1 branch
BranchTrueFalseTotal
$stdout ? : 0 0 0
694 0 ▶ $self->{_err} = $stderr ? [ split /^/m, $stderr ] : '';
Branch: 1 branch
BranchTrueFalseTotal
$stderr ? : 0 0 0
695 0 ▶ if ($outfun and $self->{_out}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outfun and $self->{"_out"}) 0 0 0
Condition0%0/3
$outfun and $self->{"_out"}
!ll&&!rl&&r
000
MC/DC0%0/2
$outfun and $self->{"_out"}
$outfun $self->{"_out"}
Truth table0%0/3
A and B
A= $outfunB= $self->{"_out"}
ABresult
0X0
100
111
696 0 for (@{$self->{_out}}) { $outfun->($_, 'out') }
697 }
698 0 ▶ if ($errfun and $self->{_err}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errfun and $self->{"_err"}) 0 0 0
Condition0%0/3
$errfun and $self->{"_err"}
!ll&&!rl&&r
000
MC/DC0%0/2
$errfun and $self->{"_err"}
$errfun $self->{"_err"}
Truth table0%0/3
A and B
A= $errfunB= $self->{"_err"}
ABresult
0X0
100
111
699 0 for (@{$self->{_err}}) { $errfun->($_, 'err') }
700 }
701 0 ▶ return ($self->{_status} ? 0 : 1);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_status'} ? : 0 0 0
702 }
703  
704 =head2 File::Rsync::list
705  
706 $out = $obj->list(@options);
707  
708 or
709  
710 $out = $obj->list(\@options);
711  
712 or
713  
714 @out = $obj->list(\@options);
715  
716 This is a wrapper for I<exec> called without a destination to get a listing.
717 It returns the output of stdout like the I<out> function below.
718 When no destination is given rsync returns the equivalent of 'ls -l' or
719 'ls -lr' modified by any include/exclude/filter parameters you specify.
720 This is useful for manual comparison without actual changes to the
721 destination or for comparing against another listing taken at a different
722 point in time.
723  
724 (As of rsync version 2.6.4-pre1 this can also be accomplished with the
725 'list-only' option regardless of whether a destination is given.)
726  
727 =cut
728  
729 sub list {
730 0 ▶ my $self = shift;
Subroutine list: not called CC=3 SCAR=24.8
Pod documented
731 0 $self->{_list_mode}++;
732 0 $self->exec(@_);
733 0 ▶ if ($self->{_out}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_out'}) { } 0 0 0
734 0 ▶ return (wantarray ? @{$self->{_out}} : $self->{_out});
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
735 } else {
736 0 return;
737 }
738 }
739  
740 =head2 File::Rsync::status
741  
742 $rval = $obj->status;
743  
744 Returns the status from last I<exec> call right shifted 8 bits.
745  
746 =cut
747  
748 sub status {
749 0 ▶ my $self = shift;
Subroutine status: not called CC=1 SCAR=6.9
Pod documented
750 0 return $self->{_status};
751 }
752  
753 =head2 File::Rsync::realstatus
754  
755 $rval = $obj->realstatus;
756  
757 Returns the real status from last I<exec> call (not right shifted).
758  
759 =cut
760  
761 sub realstatus {
762 0 ▶ my $self = shift;
Subroutine realstatus: not called CC=1 SCAR=6.9
Pod documented
763 0 return $self->{_realstatus};
764 }
765  
766 =head2 File::Rsync::err
767  
768 $aref = $obj->err;
769  
770 In scalar context this method will return a reference to an array containing
771 all output to stderr from the last I<exec> call, or zero (false) if there
772 was no output.
773 In an array context it will return an array of all output to stderr or an
774 empty list.
775 The scalar context can be used to efficiently test for the existance of output.
776 I<rsync> sends all messages from the remote I<rsync> process and any error
777 messages to stderr.
778 This method's purpose is to make it easier for you to parse that output for
779 appropriate information.
780  
781 =cut
782  
783 sub err {
784 0 ▶ my $self = shift;
Subroutine err: not called CC=3 SCAR=24.8
Pod documented
785 0 ▶ if ($self->{_err}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_err'}) { } 0 0 0
786 0 ▶ return (wantarray ? @{$self->{_err}} : $self->{_err});
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
787 } else {
788 0 return;
789 }
790 }
791  
792 =head2 File::Rsync::out
793  
794 $aref = $obj->out;
795  
796 Similar to the I<err> method, in a scalar context it returns a reference to an
797 array containing all output to stdout from the last I<exec> call, or zero
798 (false) if there was no output.
799 In an array context it returns an array of all output to stdout or an empty
800 list.
801 I<rsync> sends all informational messages (B<verbose> option) from the local
802 I<rsync> process to stdout.
803  
804 =cut
805  
806 sub out {
807 0 ▶ my $self = shift;
Subroutine out: not called CC=3 SCAR=24.8
Pod documented
808 0 ▶ if ($self->{_out}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_out'}) { } 0 0 0
809 0 ▶ return (wantarray ? @{$self->{_out}} : $self->{_out});
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
810 } else {
811 0 return;
812 }
813 }
814  
815 =head2 File::Rsync::lastcmd
816  
817 $aref = $obj->lastcmd;
818  
819 Returns the actual system command used by the last I<exec> call, or '' before
820 any calls to I<exec> for the object.
821 This can be useful in the case of an error condition to give a more
822 informative message or for debugging purposes.
823 In an array context it return an array of args as passed to the system, in
824 a scalar context it returns a space-seperated string.
825 See I<getcmd> for access to the command before execution.
826  
827 =cut
828  
829 sub lastcmd {
830 0 ▶ my $self = shift;
Subroutine lastcmd: not called CC=3 SCAR=24.8
Pod documented
831 0 ▶ if ($self->{_lastcmd}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_lastcmd'}) { } 0 0 0
832 0 return wantarray ? @{$self->{_lastcmd}} : join ' ',
833 0 ▶ @{$self->{_lastcmd}};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
834 } else {
835 0 return;
836 }
837 }
838  
839 =head1 Author
840  
841 Lee Eakin E<lt>leakin@dfw.nostrum.comE<gt>
842  
843 =head1 Credits
844  
845 The following people have contributed ideas, bug fixes, code or helped out
846 by reporting or tracking down bugs in order to improve this module since
847 it's initial release.
848 See the Changelog for details:
849  
850 Greg Ward
851  
852 Boris Goldowsky
853  
854 James Mello
855  
856 Andreas Koenig
857  
858 Joe Smith
859  
860 Jonathan Pelletier
861  
862 Heiko Jansen
863  
864 Tong Zhu
865  
866 Paul Egan
867  
868 Ronald J Kimball
869  
870 James CE Johnson
871  
872 Bill Uhl
873  
874 Peter teStrake
875  
876 Harald Flaucher
877  
878 Simon Myers
879  
880 Gavin Carr
881  
882 Petya Kohts
883  
884 Neil Hooey
885  
886 Erez Schatz
887  
888 Max Maischein
889  
890 =head1 Inspiration and Assistance
891  
892 Gerard Hickey C<PGP::Pipe>
893  
894 Russ Allbery C<PGP::Sign>
895  
896 Graham Barr C<Net::*>
897  
898 Andrew Tridgell and Paul Mackerras rsync(1)
899  
900 John Steele E<lt>steele@nostrum.comE<gt>
901  
902 Philip Kizer E<lt>pckizer@nostrum.comE<gt>
903  
904 Larry Wall perl(1)
905  
906 I borrowed many clues on wrapping an external program from the PGP modules,
907 and I would not have had such a useful tool to wrap except for the great work
908 of the B<rsync> authors. Thanks also to Graham Barr, the author of the libnet
909 modules and many others, for looking over this code. Of course I must mention
910 the other half of my brain, John Steele, and his good friend Philip Kizer for
911 finding B<rsync> and bringing it to my attention. And I would not have been
912 able to enjoy writing useful tools if not for the creator of the B<perl>
913 language.
914  
915 =head1 Copyrights
916  
917 Copyright (c) 1999-2015 Lee Eakin. All rights reserved.
918  
919 This program is free software; you can redistribute it and/or modify
920 it under the same terms as Perl itself.
921  
922 =cut
923  
924 1 1;
↑ Summary