[perl5db] refactoring + minor bug-fix.
authorShlomi Fish <shlomif@shlomifish.org>
Sat, 29 Sep 2012 22:18:40 +0000 (00:18 +0200)
committerRicardo Signes <rjbs@cpan.org>
Mon, 12 Nov 2012 14:18:27 +0000 (09:18 -0500)
The regex h\s* matches for every string that starts with "h". It should
match only if h is the only thing so a \z is needed.

lib/perl5db.pl

index bfc37ae..d4a0669 100644 (file)
@@ -4839,18 +4839,15 @@ sub cmd_h {
     my $line = shift || '';
 
     # 'h h'. Print the long-format help.
-    if ( $line =~ /^h\s*/ ) {
+    if ( $line =~ /\Ah\s*\z/ ) {
         print_help($help);
     }
 
     # 'h <something>'. Search for the command and print only its help.
-    elsif ( $line =~ /^(\S.*)$/ ) {
+    elsif ( my ($asked) = $line =~ /\A(\S.*)\z/ ) {
 
         # support long commands; otherwise bogus errors
         # happen when you ask for h on <CR> for example
-        my $asked = $1;    # the command requested
-                           # (for proper error message)
-
         my $qasked = quotemeta($asked);    # for searching; we don't
                                            # want to use it as a pattern.
                                            # XXX: finds CR but not <CR>