From 73462dbd3a661a70e7b8e40f918cefe0b176a5bb Mon Sep 17 00:00:00 2001 From: Naveed Massjouni Date: Sat, 5 May 2012 12:38:43 -0400 Subject: [PATCH] Fixed a bug in the invalid() hook. The help() function was being wrongly executed if an abbreviated command was given. --- bin/notes | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/bin/notes b/bin/notes index 8ac9c2a..fdd06fe 100755 --- a/bin/notes +++ b/bin/notes @@ -53,16 +53,10 @@ sub post_process { } sub invalid { - my ( $c, $cmd ) = @_; - $cmd //= $c->cmd; - - unless ($c->is_command($cmd)) { - my @cmds = grep { /^$cmd/ } $c->commands; - $cmd = $cmds[0] if (@cmds == 1); - } - - $c->execute( $cmd ) and return if $c->is_command( $cmd ); - $c->execute( 'help' ) and return; + my ( $c ) = @_; + my $cmd = $c->cmd; + ($cmd) = grep { /^$cmd/ } $c->commands; + $cmd ? $c->execute( $cmd ) : $c->execute( 'help' ); } App::Rad->run;