my @out;
# this is naff but it will work for now
-$line = "help" if !$line;
my $lang = $self->lang;
$lang = 'en' if !$lang;
my $h = new IO::File;
if (!open($h, "$main::localcmd/Commands_$lang.hlp")) {
+ $lang = 'en';
if (!open($h, "$main::cmd/Commands_$lang.hlp")) {
return (1, $self->msg('helpe1'));
}
}
my $in;
-$line =~ s/![\w\/]//og;
-$line =~ s/\//\.\*\//og;
-$line =~ s/^\s+//og;
-$line =~ s/\s+$//og;
+$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 $include;
+my $state = 0;
foreach $in (<$h>) {
next if $in =~ /^\#/;
chomp $in;
if ($in =~ /^===/) {
- $include = 0;
+ 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;
+ next unless $cmd =~ /^$line/i;
push @out, "$cmd $desc" unless $cmd =~ /-$/o;
- $include = 1;
+ $state = 1;
next;
}
- push @out, " $in" if $include;
+ if ($state > 0) {
+ push @out, " $in";
+ $state = 2;
+ }
}
close($h);