X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTak%2FScript.pm;h=0a4ce6ee7014f3bf2e2e6b58fcbff2fdf7750334;hb=8facab5f2e83e16470b817e2f06891f508bf50ec;hp=b7a8f5f8fc61c5812711b2cb0b737e3f0e3adfb9;hpb=3c2c021a21c598cfdebd5f361d51726cda4a14ce;p=scpubgit%2FTak.git diff --git a/lib/Tak/Script.pm b/lib/Tak/Script.pm index b7a8f5f..0a4ce6e 100644 --- a/lib/Tak/Script.pm +++ b/lib/Tak/Script.pm @@ -118,13 +118,12 @@ sub _run_local { sub _run_each { my ($self, $cmd, $code, @argv) = @_; my @targets = $self->_host_list_for($cmd); - unless (@targets or $self->options->{local}) { + unless (@targets) { $self->stderr->print("No targets for ${cmd}\n"); return; } my $opt = $self->_maybe_parse_options($code, \@argv); $self->local_client->ensure(connector => 'Tak::ConnectorService'); - $self->$code($self->local_client, $opt, @argv) if $self->options->{local}; foreach my $target (@targets) { my $remote = $self->_connection_to($target); $self->$code($remote, $opt, @argv); @@ -134,20 +133,21 @@ sub _run_each { sub _run_every { my ($self, $cmd, $code, @argv) = @_; my @targets = $self->_host_list_for($cmd); - unless (@targets or $self->options->{local}) { + unless (@targets) { $self->stderr->print("No targets for ${cmd}\n"); return; } my $opt = $self->_maybe_parse_options($code, \@argv); $self->local_client->ensure(connector => 'Tak::ConnectorService'); my @remotes = map $self->_connection_to($_), @targets; - unshift @remotes, $self->local_client if $self->options->{local}; $self->$code(\@remotes, $opt, @argv); } sub _host_list_for { my ($self, $command) = @_; my @host_spec = map split(' ', $_), @{$self->options->{host}}; + unshift(@host_spec, '-') if $self->options->{local}; + return @host_spec; } sub _connection_to {