3 # apropos - this does a grep on the command file and returns the commands
4 # that contain the string searched for
6 # Copyright (c) 1998 - Dirk Koopman G1TLH
11 my ($self, $line) = @_;
14 my $lang = $self->lang;
15 $lang = 'en' if !$lang;
19 $line = 'help' unless $line;
20 $line =~ s/\ball\b/.*/;
21 $line =~ s/\W//g; # remove dubious characters
24 my ($priv, $cmd, $param, $desc);
27 my $defh = new IO::File;
28 unless ($defh->open("$main::localcmd/Commands_en.hlp")) {
29 unless($defh->open("$main::cmd/Commands_en.hlp")) {
30 return (1, $self->msg('helpe1'));
37 unless ($h->open("$main::localcmd/Commands_$lang.hlp")) {
38 unless($h->open("$main::cmd/Commands_$lang.hlp")) {
45 foreach $in (<$defh>) {
51 ($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)};
54 next if $priv > $self->priv; # ignore subcommands that are of no concern
55 next unless $in =~ /$line/i;
56 next if $cmd =~ /-$/o;
57 push @{$cmd{$cmd}->{en}}, "$cmd$param $desc";
63 # override with any not english help
72 ($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)};
75 next if $priv > $self->priv; # ignore subcommands that are of no concern
76 next unless $in =~ /$line/i;
77 next if $cmd =~ /-$/o;
78 push @{$cmd{$cmd}->{$lang}}, "$cmd$param $desc";
85 foreach my $k (sort keys %cmd) {
87 if ($v = $cmd{$k}->{$lang}) {
89 } elsif ($v = $cmd{$k}->{en}) {
94 push @out, $self->msg('helpe2', $line) if @out == 0;