mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-03 01:43:25 +00:00
Expand uses of ranges
Ranges can now be used on: Ports: cssh localhost:{22001..22008} FQDN's: cssh host{10..20}.domain.name IP's: cssh 192.168.10.{10..20}
This commit is contained in:
parent
34f6c3e77d
commit
f1446f9be3
3 changed files with 18 additions and 3 deletions
|
@ -54,7 +54,7 @@ Ranges are of the form:
|
|||
sub expand {
|
||||
my ( $self, @items ) = @_;
|
||||
|
||||
my $range_regexp = qr/^[\w-]+\{[\w\.,]+\}$/;
|
||||
my $range_regexp = qr/[\w-]*:?\{[\w\.,]+\}/;
|
||||
my @newlist;
|
||||
foreach my $item (@items) {
|
||||
if ( $item !~ m/$range_regexp/ ) {
|
||||
|
@ -62,7 +62,7 @@ sub expand {
|
|||
next;
|
||||
}
|
||||
|
||||
my ( $base, $spec ) = $item =~ m/^(.*)?\{(.*)\}$/;
|
||||
my ( $base, $spec ) = $item =~ m/^(.*?\{(.*)\}.*?)$/;
|
||||
|
||||
for my $section ( split( /,/, $spec ) ) {
|
||||
my ( $start, $end );
|
||||
|
@ -75,7 +75,8 @@ sub expand {
|
|||
$end = $start if ( !defined($end) );
|
||||
|
||||
foreach my $number ( $start .. $end ) {
|
||||
push( @newlist, "$base$number" );
|
||||
( my $changed = $base ) =~ s/\{$spec\}/$number/;
|
||||
push( @newlist, $changed );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue