3 # "sugar script" (syntactic sugar helper) for gitolite3
5 # simple line-wise macro processor
6 # ----------------------------------------------------------------------
7 # see documentation at the end of this script
15 my $l = join( "\n", @$lines );
16 while ( $l =~ s/^macro (\w+)\b(.*?)\nend//ms ) {
20 $l =~ s/^((\w+)\b.*)/$macro{$2} ? expand($1) : $1/gem;
22 $lines = [ split "\n", $l ];
30 eval "require Text::ParseWords";
32 ( $word, @arg ) = split ' ', $l;
34 ( $word, @arg ) = Text::ParseWords::shellwords($l);
36 my $v = $macro{$word};
37 $v =~ s/%(\d+)/$arg[$1-1] or die "macro '$word' needs $1 arguments at '$l'\n"/gem;
43 Documentation is mostly by example.
49 in the ENABLE list in ~/.gitolite.rc
51 Notes on macro definition:
53 * the keywords 'macro' and 'end' should start on a new line
54 * the first word after 'macro' is the name of the macro, and the rest, until
55 the 'end', is the body
59 * the macro name should be the first word on a line
60 * the rest of the line is used as arguments to the macro
64 if your conf contains:
74 this will effectively turn into