From cb8c77011ee2bf38f60f2a906a75e25f656f35fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 8 Jun 2009 21:11:39 +0300 Subject: [PATCH] Use _split_longopt in pkg-config completion, some trivial improvements. --- CHANGES | 4 ++-- contrib/pkg-config | 36 +++++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 0693df6a..4e99a90a 100644 --- a/CHANGES +++ b/CHANGES @@ -64,8 +64,8 @@ bash-completion (1.x) * Add _split_longopt() helper for improved handling of long options that take arguments in both "--foo bar" and "--foo=bar" formats. * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig, - cpio, dpkg, iptables, make, mc, mii-diag, mii-tool, mkinitrd, postgresql, - quota, samba, smartctl, and generic long option completion + cpio, dpkg, iptables, make, mc, mii-diag, mii-tool, mkinitrd, pkg-config, + postgresql, quota, samba, smartctl, and generic long option completion (Alioth: #311398). * Add chown --from and --reference value completions. * Add chgrp --reference value completion. diff --git a/contrib/pkg-config b/contrib/pkg-config index e9ac8697..8d96031a 100644 --- a/contrib/pkg-config +++ b/contrib/pkg-config @@ -6,21 +6,39 @@ have pkg-config && _pkg_config() { - local cur + local cur prev split=false COMPREPLY=() 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 # return list of available options - COMPREPLY=( $( compgen -W '-version --modversion \ - --atleast-pkgconfig-version= --libs --libs-only-l \ - --libs-only-other --libs-only-L --cflags \ - --cflags-only-I --cflags-only-other --variable= \ - --define-variable= --exists --uninstalled \ - --atleast-version= --exact-version= --max-version= \ - --list-all --debug --print-errors --silence-errors \ - --errors-to-stdout -? --help --usage' -- $cur)) + COMPREPLY=( $( compgen -W '--version --modversion \ + --atleast-pkgconfig-version --libs --static \ + --short-errors --libs-only-l --libs-only-other \ + --libs-only-L --cflags --cflags-only-I \ + --cflags-only-other --variable --define-variable \ + --exists --uninstalled --atleast-version \ + --exact-version --max-version --list-all --debug \ + --print-errors --silence-errors --errors-to-stdout \ + --print-provides --print-requires -? --help --usage' \ + -- $cur) ) else COMPREPLY=( $( compgen -W "$( pkg-config --list-all \ 2>/dev/null | awk '{print $1}' )" -- $cur ) )