On Sat, Jul 25, 2009 at 6:28 PM, Ville Skyttä<ville.sky...@iki.fi> wrote: > On Saturday 25 July 2009, Guillaume Rousse wrote: >> I like the idea, but using stdout for output would force to use >> subshells to get the result. > [...] >> I guess there would be additional overhead added. > > It would also require the caller to take care of $IFS stuff, whereas if adding > directly to an array, functions can take care of that internally as > appropriate.
The helper functions already do a subshell and this gets removed, so isn't the overhead only in each caller repeating a subshell assignment - not in doing an additional subshell? However, to avoid the redundancy, what about two helper-helper functions `_compfset' and `_compfadd' - defaulting to IFS=$'\t\n': # @param $1 Function id # @param $2 CWORD to complete on _compfadd() { local IFS=$'\t\n' COMPREPLY=( ${comprep...@]:-} $( _compgen_$1 "$2") ) } # @param $1 Function id # @param $2 CWORD to complete on _compfset() { COMPREPLY=() _compfadd "$@" } _compgen_pci_ids() { compgen -W "$( lspci -n | awk '{print $3}')" -- "$1" } _compgen_filedir() { ... } etc. Then we could have something as: case f) _compfset filedir "$cur" The `_compfadd', `_compfset' and `_compgen_...' functions can be adorned with additional options for prefixes and suffixes, as bash's `compgen': [-P prefix] [-S suffix]. What do you think? Regards, Freddy Vulto http://fvue.nl _______________________________________________ Bash-completion-devel mailing list Bash-completion-devel@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/bash-completion-devel