From 428485086f676bb9a6948b799bb4b369e1ddec8d Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sun, 11 Mar 2012 21:45:07 +0530 Subject: [PATCH] query-rc learned '-n' to avoid the need to chomp() the result --- src/Gitolite/Rc.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Gitolite/Rc.pm b/src/Gitolite/Rc.pm index 7ed5cef..d716b6d 100644 --- a/src/Gitolite/Rc.pm +++ b/src/Gitolite/Rc.pm @@ -101,7 +101,10 @@ sub glrc { =for usage Usage: gitolite query-rc -a - gitolite query-rc + gitolite query-rc [-n] + + -a print all variables and values + -n do not append a newline Example: @@ -115,6 +118,7 @@ Example: # ---------------------------------------------------------------------- my $all = 0; +my $nonl = 0; sub query_rc { trace( 1, "rc file not found; default should be " . glrc('default-filename') ) if not glrc('filename'); @@ -123,14 +127,14 @@ sub query_rc { no strict 'refs'; - if ( $vars[0] eq '-a' ) { + if ( $all ) { for my $e (sort keys %rc) { print "$e=" . ( defined($rc{$e}) ? $rc{$e} : 'undef' ) . "\n"; } return; } - print join( "\t", map { $rc{$_} } @vars ) . "\n" if @vars; + print join( "\t", map { $rc{$_} || '' } @vars ) . ($nonl ? '' : "\n") if @vars; } # ---------------------------------------------------------------------- @@ -140,11 +144,11 @@ sub args { GetOptions( 'all|a' => \$all, + 'nonl|n' => \$nonl, 'help|h' => \$help, ) or usage(); usage("'-a' cannot be combined with other arguments") if $all and @ARGV; - return '-a' if $all; usage() if not $all and not @ARGV or $help; return @ARGV; }