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/\W//g; # remove dubious characters
23 my ($priv, $cmd, $param, $desc);
26 my $defh = new IO::File;
27 unless ($defh->open("$main::localcmd/Commands_en.hlp")) {
28 unless($defh->open("$main::cmd/Commands_en.hlp")) {
29 return (1, $self->msg('helpe1'));
36 unless ($h->open("$main::localcmd/Commands_$lang.hlp")) {
37 unless($h->open("$main::cmd/Commands_$lang.hlp")) {
44 foreach $in (<$defh>) {
50 ($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)};
53 next if $priv > $self->priv; # ignore subcommands that are of no concern
54 next unless $in =~ /$line/i;
55 next if $cmd =~ /-$/o;
56 push @{$cmd{$cmd}->{en}}, "$cmd$param $desc";
62 # override with any not english help
71 ($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)};
74 next if $priv > $self->priv; # ignore subcommands that are of no concern
75 next unless $in =~ /$line/i;
76 next if $cmd =~ /-$/o;
77 push @{$cmd{$cmd}->{$lang}}, "$cmd$param $desc";
84 foreach my $k (sort keys %cmd) {
86 if ($v = $cmd{$k}->{$lang}) {
88 } elsif ($v = $cmd{$k}->{en}) {
93 push @out, $self->msg('helpe2', $line) if @out == 0;