X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fhelp.pl;h=f0da2f82f07dcbe2ea5caa8c48e83fe048649e02;hb=080732a1948db3ce8c3ab42e117239a0db3452c7;hp=c74fad166ba4a073f70cf2d025be99040b99fcf4;hpb=4c92a7711c41cc7ba1c60d5a49a94db239032ac1;p=spider.git diff --git a/cmd/help.pl b/cmd/help.pl index c74fad16..f0da2f82 100644 --- a/cmd/help.pl +++ b/cmd/help.pl @@ -32,7 +32,7 @@ $lang = 'en' if !$lang; # The fields are:- privilege level, Language, full command name, short description # -my $h = new FileHandle; +my $h = new IO::File; if (!open($h, "$main::localcmd/Commands_$lang.hlp")) { if (!open($h, "$main::cmd/Commands_$lang.hlp")) { @@ -43,22 +43,31 @@ my $in; $line =~ s/![\w\/]//og; $line =~ s/\//\.\*\//og; +$line =~ s/^\s+//og; +$line =~ s/\s+$//og; -my $include; +# 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 =~ /^===/) { - $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);