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'));
33 unless ($lang ne 'en') {
35 unless ($h->open("$main::localcmd/Commands_$lang.hlp")) {
36 unless($h->open("$main::cmd/Commands_$lang.hlp")) {
44 foreach $in (<$defh>) {
48 $cmd{$cmd} = "$cmd $desc" if $include;
51 ($priv, $cmd, $desc) = split /\^/, $in;
52 next if $priv > $self->priv; # ignore subcommands that are of no concern
53 next unless $cmd =~ /$line/i || $desc =~ /$line/i;
54 next if $cmd =~ /-$/o;
58 $include =~ 1 if $cmd =~ /$line/i;
60 $cmd{$cmd} = "$cmd $desc" if $include;
63 # override with any not english help
70 $cmd{$cmd} = "$cmd $desc" if $include;
73 ($priv, $cmd, $desc) = split /\^/, $in;
74 next if $priv > $self->priv; # ignore subcommands that are of no concern
75 next unless $cmd =~ /$line/i || $desc =~ /$line/i;
76 next if $cmd =~ /-$/o;
80 $include =~ 1 if $cmd =~ /$line/i;
82 $cmd{$cmd} = "$cmd $desc" if $include;
86 push @out, map {$cmd{$_}} sort keys %cmd;
88 push @out, $self->msg('helpe2', $line) if @out == 0;