Skip to content

Commit

Permalink
allow strings as macro arguments
Browse files Browse the repository at this point in the history
thanks to Jason Donenfeld [1] as well as apologies for not being able to push
this out till now!

[1]: https://groups.google.com/forum/#!searchin/gitolite/macros/gitolite/3ypDcm9jTGU/PoVCoIVscaUJ
  • Loading branch information
sitaramc committed Apr 17, 2014
1 parent 5d1119c commit e492c03
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/syntactic-sugar/macros
Expand Up @@ -25,7 +25,14 @@ sub sugar_script {

sub expand {
my $l = shift;
my ( $word, @arg ) = split ' ', $l;
my ( $word, @arg );

eval "require Text::ParseWords";
if ($@) {
( $word, @arg ) = split ' ', $l;
} else {
( $word, @arg ) = Text::ParseWords::shellwords($l);
}
my $v = $macro{$word};
$v =~ s/%(\d+)/$arg[$1-1] or die "macro '$word' needs $1 arguments at '$l'\n"/gem;
return $v;
Expand Down

0 comments on commit e492c03

Please sign in to comment.