3 use File
::Compare
qw(compare);
6 my ($out, $nameattr) = @_;
7 my ($name, $attr) = @
$nameattr;
8 my ($state, $description);
11 open I
, '<', "$name.txt" or die "No such file $name.txt";
13 if (/^git[a-z0-9-]*\(([0-9])\)$/) {
21 if ($state == 1 && /^----$/) {
25 next if ($state != 2);
31 if (!defined $description) {
32 die "No description found in $name.txt";
34 if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
35 print $out "linkgit:$name\[$mansection\]::\n\t";
36 if ($attr =~ / deprecated /) {
37 print $out "(deprecated) ";
39 print $out "$text.\n\n";
42 die "Description does not match $name: $description";
46 my ($input, @categories) = @ARGV;
50 last if /^### command list/;
58 my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/;
59 $attr = '' unless defined $attr;
60 push @
{$cmds{$cat}}, [$name, " $attr "];
64 for my $out (@categories) {
65 my ($cat) = $out =~ /^cmds-(.*)\.txt$/;
66 open O
, '>', "$out+" or die "Cannot open output file $out+";
67 for (@
{$cmds{$cat}}) {
72 if (-f
"$out" && compare
("$out", "$out+") == 0) {
76 print STDERR
"$out\n";
77 rename "$out+", "$out";