[Bash-completion-devel] hostname completion issues

Freddy Vulto fvulto at gmail.com
Thu Jun 18 19:56:41 UTC 2009


On Thu, Jun 18, 2009 at 10:34 AM, Guillaume
Rousse<Guillaume.Rousse at inria.fr> wrote:
> _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*

A mandatory argument which is allowed to be empty sounds like a
contradiction to me, that's why I made it an option.
I think it was just wrong of me to quote the "$optconfigfile" argument
to `_known_hosts_real'.  This caused a call like this:

    _known_hosts_real -a "" -h $cur

which caused `getopts' to stop processing at the empty argument ("").
I can't reproduce behaviour with your example '_known_host_real -h ""
-a': -h correctly gets set to "".
I've put an error message in _known_hosts_real if there are left-over arguments.
Can you give this a try? (commit 127eaafb540433ed55089691dd3b9e001c92e5b9)

Greetings, Freddy



More information about the Bash-completion-devel mailing list