I am using the cmd module to create a simple shell. For two commands, I have two different lists. For one, the completion works as expected, but the other it doesn't.
[Good list] IntList="eth0", "eth1", "eth2"
[Bad List] IntList="heth-0-0","heth-0-1","heth-0-2","heth-0-3","heth-0-4"
My routine looks like:
def complete_interface(self, text, line, begidx, endidx):
return[ f for f in IntList if f.startswith(text)]
When I run the shell and hit twice after 'interface', I see
Delem(eth2): interface eth
eth0 eth1 eth2
Delem(eth2): interface eth
eth0 eth1 eth2
Delem(eth2): interface eth
But when I use the other list, I get
Delem(heth0-0): interface heth-0-heth-0-
No such interface: heth-0-heth-0-
Delem(heth0-0):
See how it is appending the beginning string with the second list? Not sure how to debug this...