Hi Ed,
I think I understand the issue and have a solution. Comments are always
welcome. :)
On Thu, May 31, 2012 at 3:32 PM, Ed Greshko <Ed.Greshko(a)greshko.com> wrote:
On 05/31/2012 08:29 PM, suvayu ali wrote:
> I guess that means I have to figure out how this dynamic loading works
> and I have to change my "complete -F <completion_fn> <wrapper>"
calls
> accordingly.
>
> Thanks a lot for the help and discussion. :)
Yeah....strange. The bash version is the same on F16 and F17. Let
me know what you find. I'm scratching my head and hope it doesn't
interfere with a good night's sleep. :-)
Since bash 4.1, bash complete builtin supports the -D option. It lets
you specify a default completion function which takes the calling
command as the first argument. Using this facilty one can setup dynamic
completion loading. This resolves long shell starting time issues with
heavy use of the bash completion package.
Since bash-completion 1.99 (default for F17) support for the old method
has been removed completely (which also means it doesn't support < Bash
4.1, i.e. SLC5, RHEL5 et al).
By default the _completion_loader is used to dynamically load completion
functions. If you are using completion functions for other utilities for
your wrappers, these are unavailable until _completion_loader has been
invoked for the utility once; hence completion on the wrapper fails for
the very first try.
The work wround is to define a custom completion loader yourself that
sources the appropriate files for your wrappers and falls back to the
_completion_loader otherwise. So in this particular case the following
works very well:
# custom completion loader
function _custom_completion_loader() {
local cmd=$1
case $cmd in
find_ext)
{ declare -F _find &> /dev/null || \
source /usr/share/bash-completion/completions/find \
&> /dev/null;
} && complete -F _find find_ext
;;
*)
_completion_loader $cmd
esac
return 124
}
# default completion function that wraps around _completion_loader
complete -D -F _custom_completion_loader
I hope this helps someone in the future.
--
Suvayu
Open source is the future. It sets us free.