[Bash-completion-devel] hostname completion issues

Guillaume Rousse Guillaume.Rousse at inria.fr
Thu Jun 18 08:34:50 UTC 2009


Freddy Vulto a écrit :
> On Wed, Jun 17, 2009 at 10:26 PM, Ville Skyttä<ville.skytta at iki.fi> wrote:
>> Some recent changes (known hosts stuff?) have broken ssh hostname completion
>> quite badly for me in git master.
> ...
>> This is with bash 3.2.39(1)-release.  Anyone else seeing this?  Anyone working
>> on known hosts completion?
> 
> Yes, I'm having the same problem.  I think it's caused by my recent
> changes concerning _known_hosts_real.  From a quick look it appears
> the `getopts' in _known_hosts_real isn't catching the -h "$cur"
> option.  I'll have a further look as soon as I have some more time.
_known_hosts_real was supposed to have a mandatory host argument, by 
contrast to _known_hosts. Otherwise, there is no use to split those two 
functions, we could use a single one.

And I favor the splitted solution because:
- calling directly the function with the proper behaviour is faster than 
having this function test its argument at runtime to select which 
behavior to use
- distinguishing between completion functions (those directly attached 
to a command) and helper functions (those called by completion 
functions) make the code easier to maintain
- bash isn't wise enough to to distinguish between an empty string 
argument and an non-existing one: calling the '_known_host -a' function 
with no current host will call '_known_host_real -h "" -a', and result 
in completion for hosts called -a*

-- 
BOFH excuse #97:

Small animal kamikaze attack on power supplies



More information about the Bash-completion-devel mailing list