/usr/share/doc/monotone/contrib/get_stdio.pl is in monotone 1.1-9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #!/usr/bin/perl
#Timothy Brownawell
#get_stdio.pl filename n
#Get the output from command n as one piece
#filename holds the output from "monotone automate stdio"
$x="";
open $file, $ARGV[0];
while(<$file>)
{
$x = $x . $_;
}
# packet is cmdnum:errcode:(last|more):size:contents
# note that contents may contain newlines (or may even be binary)
# this does:
# for i in split_into_packets($x)
# $results[i.cmdnum] += i.contents
#
# print $results[n]
# read a packet from $x (the contents of the file)
while($x =~ /(\d+)\:\d+\:[lm]\:(\d+)\:/s)
{# $1, $2, etc (what was matched by the parentheses) are dynamically scoped
$m=int($2);
my $n="";
$x = $'; #' # what's left after the end of the match
for(;$m > 0; $m--) # read $m bytes, leaving $x as what's left
{
$x =~ /(.)/s;
$n = $n . $1;
$x = $'; #' # gedit syntax coloring gets messed up on $' .
}
$results[$1] = $results[$1] . $n; # the $1 from the while
}
print $results[$ARGV[1]];
|