-my $include = 0;
-my @in = <H>;
-close(H);
-
-foreach $in (@in) {
- next if $in =~ /^\s*\#/;
- chomp $in;
- if ($in =~ /^===/) {
- $include = 0;
- $in =~ s/=== //;
- my ($priv, $lang, $cmd, $desc) = split /\^/, $in;
- next if $priv > $self->priv; # ignore subcommands that are of no concern
- next if $self->lang && $self->lang ne $lang;
- push @out, "$cmd - $desc";
- $include = 1;
- next;
- }
- push @out, $in if $include;
+
+$line =~ s/[^\w\/]//g;
+$line =~ s/\//\.\*\//g;
+$line =~ s/^\s+//g;
+$line =~ s/\s+$//g;
+$line = "help" if $line =~ /^\s*$/;
+
+# sort out aliases
+my $alias = CmdAlias::get_hlp($line);
+$line = $alias if $alias;
+
+my $state = 0;
+foreach $in (<$h>) {
+ next if $in =~ /^\#/;
+ chomp $in;
+ if ($in =~ /^===/) {
+ last if $state == 2; # come out on next command
+ $in =~ s/=== //;
+ my ($priv, $cmd, $desc) = split /\^/, $in;
+ next if $priv > $self->priv; # ignore subcommands that are of no concern
+ next unless $cmd =~ /^$line/i;
+ push @out, "$cmd $desc" unless $cmd =~ /-$/o;
+ $state = 1;
+ next;
+ }
+ if ($state > 0) {
+ push @out, " $in";
+ $state = 2;
+ }