From dc5e5a1cfc8ef73271ee7f085784b7c2f1ec7f76 Mon Sep 17 00:00:00 2001 From: ianmacd <> Date: Thu, 7 Mar 2002 16:16:43 +0000 Subject: [PATCH] - _rpm(): handle query of uninstalled packages when options are not concatenated, i.e. rpm -qp worked, but rpm -q -p did not. Further complicated by fact that other options could be interspersed, e.g. rpm -q -l -p -i, and that partial concatenation could be given, e.g. rpm -q -ipl --- bash_completion | 54 ++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/bash_completion b/bash_completion index 89abab51..2cb0ab13 100644 --- a/bash_completion +++ b/bash_completion @@ -1,6 +1,6 @@ # bash_completion - some programmable completion functions for bash 2.05a # -# $Id: bash_completion,v 1.180 2002/03/06 20:24:06 ianmacd Exp $ +# $Id: bash_completion,v 1.181 2002/03/07 17:16:43 ianmacd Exp $ # # Copyright (C) Ian Macdonald # @@ -914,6 +914,21 @@ _rpm() COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) ) } + uninstalled_packages() + { + # complete on list of relevant options + COMPREPLY=( $( compgen -W '--scripts --root --rcfile \ + --whatprovides --whatrequires --requires --triggeredby \ + --ftpport --ftpproxy --httpproxy --httpport --provides \ + --triggers --dump --changelog --dbpath --filesbypkg --define \ + --eval --pipe --showrc --info --list --state --docfiles \ + --configfiles --queryformat --conflicts --obsoletes' -- $cur ) ) + # return if $cur is an option + [[ "$cur" == -* ]] && return 0 + # add a list of RPMS to possible completions + file_glob rpm + } + local cur prev COMPREPLY=() @@ -1005,17 +1020,7 @@ _rpm() file_glob rpm ;; -q*p*) - # complete on list of relevant options - COMPREPLY=( $( compgen -W '--scripts --root --rcfile \ - --whatprovides --whatrequires --requires --triggeredby \ - --ftpport --ftpproxy --httpproxy --httpport --provides \ - --triggers --dump --changelog --dbpath --filesbypkg --define \ - --eval --pipe --showrc --info --list --state --docfiles \ - --configfiles --queryformat --conflicts --obsoletes' -- $cur ) ) - # return if $cur is an option - [[ "$cur" == -* ]] && return 0 - # add a list of RPMS to possible completions - file_glob rpm + uninstalled_packages ;; -*f) # standard filename completion @@ -1030,15 +1035,22 @@ _rpm() add_package_list ;; -q*) - # complete on list of relevant options - COMPREPLY=( $( compgen -W '--scripts --root --rcfile \ - --whatprovides --whatrequires --requires --triggeredby \ - --ftpport --ftpproxy --httpproxy --httpport --provides \ - --triggers --dump --changelog --dbpath --specfile \ - --querybynumber --last --filesbypkg --define --eval --pipe \ - --showrc --info --list --state --docfiles --configfiles \ - --queryformat --conflicts --obsoletes --pkgid --hdrid \ - --fileid --tid' -- $cur ) ) + # check whether we're querying installed or uninstalled + if [ "${COMP_LINE#*-*([^ ])p}" != "$COMP_LINE" ]; then + # there's a -p on the line + uninstalled_packages + return 0 + else + # complete on list of relevant options + COMPREPLY=( $( compgen -W '--scripts --root --rcfile \ + --whatprovides --whatrequires --requires --triggeredby \ + --ftpport --ftpproxy --httpproxy --httpport --provides \ + --triggers --dump --changelog --dbpath --specfile \ + --querybynumber --last --filesbypkg --define --eval \ + --pipe --showrc --info --list --state --docfiles \ + --configfiles --queryformat --conflicts --obsoletes \ + --pkgid --hdrid --fileid --tid' -- $cur ) ) + fi # return if $cur is an option [[ "$cur" == -* ]] && return 0 # don't complete on packages if we are querying all packages