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

Does anyone here have some in-depth knowledge of Term::ReadLine::Gnu? For the most part, it works, but when I get into more complicated behavior tuning I have nowhere to turn. The documentation is pretty shoddy, not very verbose with descriptions.

Basically everything is working fine, except for fact that when I have several selections to choose from that all begin with the same word, the tab-completion just doesn't seem to work right. For example:

Let's say the valid tab-completion options are:

Foo Bar 001
Foo Bar 002
Foo Bar Biz Baz
Foo Bar 004

When I am at the readline prompt and hit tab, immediately the word "Foo Bar " comes up. Ok, thats fine since all my options start with "Foo Bar", however, then I hit tab again and another "Foo Bar " is added. And so on everytime I hit tab "Foo Bar " is added.

The correct behavior (i.e. the bash behavior) would be to put "Foo Bar " on the prompt after the first tab, but then with subsequent ones, list the options again. If I added a 0 to it: "Foo Bar 0"<tab> that would just display entries 1,2 and 4. And so on.

Right now I can't get that behavior. So really, the tab-completion doesn't complete at all, if I keep hitting tab it'll just fill the prompt with "Foo Bar" over and over.

How can I get this to behave exactly (or closer) to the bash prompt behavior?

Thanks for any help.

- Nick

Replies are listed 'Best First'.
Re: tab-completion problems
by ikegami (Patriarch) on Jan 18, 2005 at 18:52 UTC

    The difference is that the bash prompt will escape "Foo Bar " to "Foo\ Bar\ ". When the cursor is at the end of "Foo Bar ", Term::ReadLine::Gnu thinks you're starting a new word. When the cursor is at the end of "Foo\ Bar\ ", bash realizes the begining of the word is the 'F'. Term::ReadLine::Gnu needs to use some sort of escape mechanism before it has any hopes of knowing whether you're completing "Foo Bar ", "Bar " or starting a new argument.

    I don't have any solutions. I'm just giving an alternate description of the problem, in the hopes that it may yield an idea on how to solve it.