Re: Issue with bash completion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx> 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.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux