hotshot has asked for the wisdom of the Perl Monks concerning the following question:

hello monks

I'm using Term::TeadLine in my shell program for some purposes. One of them is the tab completion. my shell have menus so for example:
# if I write main > one two # I should get new prompt main\one\two >
I manage to do so by:
my $term = new Term::ReadLine 'Command Line Interface'; my $attribs = $term->Attribs; $attribs->{attempted_completion_function} = \&tabCompletionFunction; sub tabCompletionFunction { my ($text, $line, $start, $end) = @_; my @tmp = split(/\s+/, $line); unshift(@tmp, @prompt); # the completion should be relative to cur +rent prompt $attribs->{completion_word} = &getTabCompletionArray(\@tmp); return $term->completion_matches($text, $attribs->{list_completion_f +unction}); }
each time the tab button will be pressed, the completion will be made relatively to the current prompt and the info in the input buffer in $line.

This works perfectly except the case when I enter in the command line a char that no word in the completion array starts with, for example when the array is:
$completionsArray = qw(one two three four); # found by &getTabComple +tionArray
and the input is:
current prompt > xdd
what I should expect is that no completion should be preformed, but what actually happens is that if in the current directory (where my shell program runs from) theres a file/directory that starts with xdd, the completion will be made. I guess it uses the defaultfile_completion_function, but I specified list_completion_function intentionaly so this won't happen, Anyone knows why this happens and how can I fix that not to show anything if no matches in the completion array?


Hotshot