#!/usr/bin/perl -w # Copyright 2007 Anthony Towns # GPL v2 or later. use strict; open LIST, "mr list |" or die "mr list: $!"; my @repos = (); while () { next unless m,^mr list: (/.*)\s*$,; push @repos, $1; } close(LIST); doall(@repos); sub doall { my @args = @_; my @fhs = (); my $args = join(" ", @ARGV); for my $x (@args) { my $mrout = undef; open $mrout, "(cd $x && mr $args 2>&1) |"; push @fhs, $mrout; } my @out = "" x length(@fhs); my $any = 1; $| = 1; print "Working..."; while ($any) { my ($rin, $rout) = ('',''); my $nfound; for my $x (@fhs) { next unless defined $x; vec($rin, fileno($x),1) = 1; } $nfound = select($rout=$rin, undef, undef, 1); $any = 0; for my $i (0..$#fhs) { my $fh = $fhs[$i]; next unless defined $fh; $any = 1; if (vec($rout, fileno($fh),1) == 1) { my $r = ''; if (sysread($fh, $r, 1024) == 0) { close($fh); $fhs[$i] = undef; } $out[$i] .= $r; } } } print "\n"; my $out = ''; for my $i (0..$#fhs) { $out .= $out[$i] . "\n"; } my $nls; ($nls = $out) =~ y/\n/x/d; if (length($nls) > 20 and open(LESS, "| less")) { $out =~ s/^.*\r//mg; print LESS $out; close LESS; } else { print $out; } }