Use _split_longopt in pkg-config completion, some trivial improvements.

This commit is contained in:
Ville Skyttä 2009-06-08 21:11:39 +03:00
parent 079aca216a
commit cb8c77011e
2 changed files with 29 additions and 11 deletions

View File

@ -64,8 +64,8 @@ bash-completion (1.x)
* Add _split_longopt() helper for improved handling of long options that * Add _split_longopt() helper for improved handling of long options that
take arguments in both "--foo bar" and "--foo=bar" formats. take arguments in both "--foo bar" and "--foo=bar" formats.
* Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig, * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig,
cpio, dpkg, iptables, make, mc, mii-diag, mii-tool, mkinitrd, postgresql, cpio, dpkg, iptables, make, mc, mii-diag, mii-tool, mkinitrd, pkg-config,
quota, samba, smartctl, and generic long option completion postgresql, quota, samba, smartctl, and generic long option completion
(Alioth: #311398). (Alioth: #311398).
* Add chown --from and --reference value completions. * Add chown --from and --reference value completions.
* Add chgrp --reference value completion. * Add chgrp --reference value completion.

View File

@ -6,21 +6,39 @@
have pkg-config && have pkg-config &&
_pkg_config() _pkg_config()
{ {
local cur local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in
--@(?(define-)variable|@(atleast?(-pkgconfig)|exact|max)-version))
# argument required but no completions available
return 0
;;
-\?|--help|--version|--usage)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
# return list of available options # return list of available options
COMPREPLY=( $( compgen -W '-version --modversion \ COMPREPLY=( $( compgen -W '--version --modversion \
--atleast-pkgconfig-version= --libs --libs-only-l \ --atleast-pkgconfig-version --libs --static \
--libs-only-other --libs-only-L --cflags \ --short-errors --libs-only-l --libs-only-other \
--cflags-only-I --cflags-only-other --variable= \ --libs-only-L --cflags --cflags-only-I \
--define-variable= --exists --uninstalled \ --cflags-only-other --variable --define-variable \
--atleast-version= --exact-version= --max-version= \ --exists --uninstalled --atleast-version \
--list-all --debug --print-errors --silence-errors \ --exact-version --max-version --list-all --debug \
--errors-to-stdout -? --help --usage' -- $cur)) --print-errors --silence-errors --errors-to-stdout \
--print-provides --print-requires -? --help --usage' \
-- $cur) )
else else
COMPREPLY=( $( compgen -W "$( pkg-config --list-all \ COMPREPLY=( $( compgen -W "$( pkg-config --list-all \
2>/dev/null | awk '{print $1}' )" -- $cur ) ) 2>/dev/null | awk '{print $1}' )" -- $cur ) )