From 4400fd90c12438b6587d9ffee1384acb06b4dd88 Mon Sep 17 00:00:00 2001 From: Lorenzo Cappelletti Date: Sat, 26 Apr 2014 23:04:36 +0200 Subject: [PATCH] Call help() before loadconfig() This avoids annoying error messages from config files being debugged when running 'mr help'. Signed-off-by: Lorenzo Cappelletti --- mr | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/mr b/mr index ddc0738..4cd3c2e 100755 --- a/mr +++ b/mr @@ -1551,10 +1551,7 @@ sub dispatch { my $action=shift; # actions that do not operate on all repos - if ($action eq 'help') { - help(@ARGV); - } - elsif ($action eq 'config') { + if ($action eq 'config') { config(@ARGV); } elsif ($action eq 'register') { @@ -1582,7 +1579,27 @@ sub dispatch { } sub help { - exec($config{''}{DEFAULT}{help}) || die "exec: $!"; + my $help=q# + case `uname -s` in + SunOS) + SHOWMANFILE="man -f" + ;; + Darwin) + SHOWMANFILE="man" + ;; + *) + SHOWMANFILE="man" + ;; + esac + if [ ! -e "$MR_PATH" ]; then + error "cannot find program path" + fi + tmp=$(mktemp -t mr.XXXXXXXXXX) || error "mktemp failed" + trap "rm -f $tmp" exit + pod2man -c mr "$MR_PATH" > "$tmp" || error "pod2man failed" + $SHOWMANFILE "$tmp" || error "man failed" + #; + exec($help) || die "exec: $!"; } sub config { @@ -1825,6 +1842,7 @@ sub exitstats { sub main { getopts(); init(); + help(@ARGV) if $ARGV[0] eq 'help'; startingconfig(); loadconfig($HOME_MR_CONFIG); @@ -2081,25 +2099,6 @@ vcsh_trusted_checkout = vcsh run "$MR_REPO" git clone $url $repo veracity_trusted_checkout = vv clone $url $repo -help = - case `uname -s` in - SunOS) - SHOWMANFILE="man -f" - ;; - Darwin) - SHOWMANFILE="man" - ;; - *) - SHOWMANFILE="man" - ;; - esac - if [ ! -e "$MR_PATH" ]; then - error "cannot find program path" - fi - tmp=$(mktemp -t mr.XXXXXXXXXX) || error "mktemp failed" - trap "rm -f $tmp" exit - pod2man -c mr "$MR_PATH" > "$tmp" || error "pod2man failed" - $SHOWMANFILE "$tmp" || error "man failed" list = true config = bootstrap = -- 2.39.5