[Bash-completion-devel] hostname completion issues
Guillaume Rousse
Guillaume.Rousse at inria.fr
Sat Jul 25 11:09:00 UTC 2009
Freddy Vulto a écrit :
> On Fri, Jul 3, 2009 at 11:15 PM, Guillaume
> Rousse<Guillaume.Rousse at inria.fr> wrote:
>> However, using this prefix for distinguishing helper function setting or
>> adding to COMPREPLY is fine. In this regard, we shoud rename the following
>> ones:
>> - _filedir -> _add_filedirs
>> - _pci_ids -> _add_pc_ids
>> etc...
>
> I have another idea, maybe we can take it even one step further: Why
> don't we let the helper functions output to stdout instead of adding
> to COMPREPLY directly? A suitable prefix for this function range
> would then be `_compgen':
>
> - _compgen_known_hosts
> - _compgen_filedir
> - _compgen_pc_ids
> - ...
>
> Rationale:
>
> It makes helper functions less coupled, thus better.
>
> Outputting to stdout is in analogy with bash's `compgen'.
>
> Outputting to stdout is in analogy with normal bash function
> behaviour: input via function parameters, output via stdout.
>
> The `_compgen' prefix would also serve as a start for letting
> bash-completion functions reside in some kind of `comp' namespace in
> order to make it less likely for bash-completion functions to clash
> with user functions 'out there'.
>
> What do you think?
I like the idea, but using stdout for output would force to use
subshells to get the result.
instead of:
case f)
_filedir
;;
we would have something as:
case f)
COMPREPLY = ( $( _compgen_filedir $cur ) )
;;
I guess there would be additional overhead added.
--
BOFH excuse #152:
My pony-tail hit the on/off switch on the power strip.
More information about the Bash-completion-devel
mailing list