4 # apropos - this does a grep on the command file and returns the commands
5 # that contain the string searched for
7 # Copyright (c) 1998 - Dirk Koopman G1TLH
12 my ($self, $line) = @_;
15 my $lang = $self->lang;
16 $lang = 'en' if !$lang;
19 $line = 'help' unless $line;
20 $line =~ s/\W//g; # remove dubious characters
22 my ($priv, $cmd, $desc);
25 my $defh = new IO::File;
26 unless ($defh->open("$main::localcmd/Commands_en.hlp")) {
27 unless($defh->open("$main::cmd/Commands_en.hlp")) {
28 return (1, $self->msg('helpe1'));
35 unless ($h->open("$main::localcmd/Commands_$lang.hlp")) {
36 unless($h->open("$main::cmd/Commands_$lang.hlp")) {
44 foreach $in (<$defh>) {
49 $cmd{$cmd} = "$cmd $desc" if $include;
52 ($priv, $cmd, $desc) = split /\^/, $in;
53 next if $priv > $self->priv; # ignore subcommands that are of no concern
54 next unless $cmd =~ /$line/i || $desc =~ /$line/i;
55 next if $cmd =~ /-$/o;
59 $include = 1 if $cmd =~ /$line/i;
61 $cmd{$cmd} = "$cmd $desc" if $include;
64 # override with any not english help
72 $cmd{$cmd} = "$cmd $desc" if $include;
75 ($priv, $cmd, $desc) = split /\^/, $in;
76 next if $priv > $self->priv; # ignore subcommands that are of no concern
77 next unless $cmd =~ /$line/i || $desc =~ /$line/i;
78 next if $cmd =~ /-$/o;
82 $include = 1 if $cmd =~ /$line/i;
84 $cmd{$cmd} = "$cmd $desc" if $include;
88 push @out, map {$cmd{$_}} sort keys %cmd;
90 push @out, $self->msg('helpe2', $line) if @out == 0;