- _rpm(): major clean-up, including removal of dashify()
- _rpm(): fix bug that caused --prefix, --relocate and --root to not complete on directories
This commit is contained in:
parent
d29b19a324
commit
f0af45516a
145
bash_completion
145
bash_completion
@ -1,6 +1,6 @@
|
|||||||
# bash_completion - some programmable completion functions for bash 2.05a
|
# bash_completion - some programmable completion functions for bash 2.05a
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.151 2002/02/27 00:35:39 ianmacd Exp $
|
# $Id: bash_completion,v 1.152 2002/02/27 01:14:52 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -611,24 +611,11 @@ _cvs()
|
|||||||
}
|
}
|
||||||
[ "$have" ] && complete -F _cvs -o default cvs
|
[ "$have" ] && complete -F _cvs -o default cvs
|
||||||
|
|
||||||
# rpm(8) completion. This is quite comprehensive now and covers rpm 4.x
|
# rpm(8) completion
|
||||||
#
|
#
|
||||||
have rpm &&
|
have rpm &&
|
||||||
_rpm()
|
_rpm()
|
||||||
{
|
{
|
||||||
dashify()
|
|
||||||
{
|
|
||||||
local i
|
|
||||||
|
|
||||||
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
|
|
||||||
if [ ${#COMPREPLY[i]} -le 2 ]; then
|
|
||||||
COMPREPLY[i]=-${COMPREPLY[i]}
|
|
||||||
else
|
|
||||||
COMPREPLY[i]=--${COMPREPLY[i]}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
add_package_list()
|
add_package_list()
|
||||||
{
|
{
|
||||||
if [ -r /var/log/rpmpkgs -a \
|
if [ -r /var/log/rpmpkgs -a \
|
||||||
@ -646,53 +633,47 @@ _rpm()
|
|||||||
{
|
{
|
||||||
_expand || return 0
|
_expand || return 0
|
||||||
|
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( compgen -f -X "!*.$1" $cur ) )
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -f -X "!*.$1" -- $cur ) )
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d $cur ) )
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
local cur cur_nodash prev
|
local cur prev
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
cur_nodash=${cur#-}
|
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
if [ $COMP_CWORD -eq 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
# first parameter on line
|
# first parameter on line
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-b*)
|
-b*)
|
||||||
COMPREPLY=( $( compgen -W 'ba bb bc bi bl bp bs' \
|
COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\
|
||||||
$cur_nodash ) )
|
-- $cur ) )
|
||||||
dashify
|
|
||||||
return 0
|
|
||||||
;;
|
;;
|
||||||
-t*)
|
-t*)
|
||||||
COMPREPLY=( $( compgen -W 'ta tb tc ti tl tp ts' \
|
COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\
|
||||||
$cur_nodash ) )
|
-- $cur ) )
|
||||||
dashify
|
|
||||||
return 0
|
|
||||||
;;
|
;;
|
||||||
--*)
|
--*)
|
||||||
COMPREPLY=( $( compgen -W 'help version initdb \
|
COMPREPLY=( $( compgen -W '--help --version --initdb \
|
||||||
checksig recompile rebuild resign addsign rebuilddb \
|
--checksig --recompile --rebuild --resign --addsign \
|
||||||
showrc setperms setugids tarbuild eval install \
|
--rebuilddb --showrc --setperms --setugids --tarbuild \
|
||||||
upgrade query freshen erase verify querytags rmsource \
|
--eval --install --upgrade --query --freshen --erase \
|
||||||
rmspec clean' ${cur_nodash#-} ) )
|
--verify --querytags --rmsource --rmspec --clean' -- \
|
||||||
dashify
|
$cur ) )
|
||||||
return 0
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
COMPREPLY=( $( compgen -W 'b e F i q t U V' \
|
COMPREPLY=( $( compgen -W '-b -e -F -i -q -t -U -V' \
|
||||||
$cur_nodash ) )
|
-- $cur ) )
|
||||||
dashify
|
|
||||||
return 0
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--@(db|exclude)path|prefix|relocate|root)
|
--@(@(db|exclude)path|prefix|relocate|root))
|
||||||
COMPREPLY=( $( compgen -d $cur ) )
|
COMPREPLY=( $( compgen -d -- $cur ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--eval)
|
--eval)
|
||||||
@ -702,11 +683,11 @@ _rpm()
|
|||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--pipe)
|
--pipe)
|
||||||
COMPREPLY=( $( compgen -c $cur ) )
|
COMPREPLY=( $( compgen -c -- $cur ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--rcfile)
|
--rcfile)
|
||||||
COMPREPLY=( $( compgen -f $cur ) )
|
COMPREPLY=( $( compgen -f -- $cur ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--specfile)
|
--specfile)
|
||||||
@ -729,13 +710,14 @@ _rpm()
|
|||||||
case "${COMP_WORDS[1]}" in
|
case "${COMP_WORDS[1]}" in
|
||||||
-@([iFU]*|-install|-freshen|-upgrade))
|
-@([iFU]*|-install|-freshen|-upgrade))
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'percent force test replacepkgs \
|
COMPREPLY=( $( compgen -W '--percent --force --test \
|
||||||
replacefiles root excludedocs includedocs noscripts rcfile \
|
--replacepkgs --replacefiles --root --excludedocs \
|
||||||
ignorearch dbpath prefix ignoreos nodeps allfiles ftpproxy \
|
--includedocs --noscripts --rcfile --ignorearch --dbpath \
|
||||||
ftpport justdb httpproxy httpport noorder relocate badreloc \
|
--prefix --ignoreos --nodeps --allfiles --ftpproxy --ftpport \
|
||||||
notriggers excludepath ignoresize oldpackage define eval \
|
--justdb --httpproxy --httpport --noorder --relocate \
|
||||||
pipe queryformat repackage' ${cur_nodash#-} ))
|
--badreloc --notriggers --excludepath --ignoresize \
|
||||||
dashify
|
--oldpackage --define --eval --pipe --queryformat \
|
||||||
|
--repackage' -- $cur ) )
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# add a list of RPMS to possible completions
|
# add a list of RPMS to possible completions
|
||||||
@ -744,12 +726,12 @@ _rpm()
|
|||||||
;;
|
;;
|
||||||
-q*p*)
|
-q*p*)
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
|
COMPREPLY=( $( compgen -W '--scripts --root --rcfile \
|
||||||
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
|
--whatprovides --whatrequires --requires --triggeredby \
|
||||||
httpport provides triggers dump changelog dbpath filesbypkg \
|
--ftpport --ftpproxy --httpproxy --httpport --provides \
|
||||||
define eval pipe showrc info list state docfiles \
|
--triggers --dump --changelog --dbpath --filesbypkg --define \
|
||||||
configfiles queryformat conflicts obsoletes' ${cur_nodash#-} ) )
|
--eval --pipe --showrc --info --list --state --docfiles \
|
||||||
dashify
|
--configfiles --queryformat --conflicts --obsoletes' -- $cur ) )
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# add a list of RPMS to possible completions
|
# add a list of RPMS to possible completions
|
||||||
@ -758,14 +740,13 @@ _rpm()
|
|||||||
;;
|
;;
|
||||||
-*f)
|
-*f)
|
||||||
# standard filename completion
|
# standard filename completion
|
||||||
COMPREPLY=( $( compgen -f $cur ) )
|
COMPREPLY=( $( compgen -f -- $cur ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-@(e|-erase))
|
-@(e|-erase))
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'allmatches noscripts notriggers \
|
COMPREPLY=( $( compgen -W '--allmatches --noscripts \
|
||||||
nodeps test repackage' ${cur_nodash#-} ) )
|
--notriggers --nodeps --test --repackage' -- $cur ) )
|
||||||
dashify
|
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
add_package_list
|
add_package_list
|
||||||
@ -773,13 +754,14 @@ _rpm()
|
|||||||
;;
|
;;
|
||||||
-q*)
|
-q*)
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
|
COMPREPLY=( $( compgen -W '--scripts --root --rcfile \
|
||||||
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
|
--whatprovides --whatrequires --requires --triggeredby \
|
||||||
httpport provides triggers dump changelog dbpath specfile \
|
--ftpport --ftpproxy --httpproxy --httpport --provides \
|
||||||
querybynumber last filesbypkg define eval pipe showrc info \
|
--triggers --dump --changelog --dbpath --specfile \
|
||||||
list state docfiles configfiles queryformat conflicts \
|
--querybynumber --last --filesbypkg --define --eval --pipe \
|
||||||
obsoletes pkgid hdrid fileid tid' ${cur_nodash#-} ) )
|
--showrc --info --list --state --docfiles --configfiles \
|
||||||
dashify
|
--queryformat --conflicts --obsoletes --pkgid --hdrid \
|
||||||
|
--fileid --tid' -- $cur ) )
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# don't complete on packages if we are querying all packages
|
# don't complete on packages if we are querying all packages
|
||||||
@ -789,9 +771,7 @@ _rpm()
|
|||||||
;;
|
;;
|
||||||
-@(K|-checksig))
|
-@(K|-checksig))
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'nopgp nogpg nomd5' \
|
COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5' -- $cur ) )
|
||||||
${cur_nodash#-} ) )
|
|
||||||
dashify
|
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# add a list of RPMS to possible completions
|
# add a list of RPMS to possible completions
|
||||||
@ -800,9 +780,8 @@ _rpm()
|
|||||||
;;
|
;;
|
||||||
-@([Vy]*|-verify))
|
-@([Vy]*|-verify))
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'root rcfile dbpath nodeps nofiles \
|
COMPREPLY=( $( compgen -W '--root --rcfile --dbpath --nodeps \
|
||||||
noscripts nomd5' ${cur_nodash#-} ) )
|
--nofiles --noscripts --nomd5' -- $cur ) )
|
||||||
dashify
|
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
add_package_list
|
add_package_list
|
||||||
@ -810,10 +789,10 @@ _rpm()
|
|||||||
;;
|
;;
|
||||||
-[bt]*)
|
-[bt]*)
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
|
COMPREPLY=( $( compgen -W '--short-circuit --timecheck \
|
||||||
rmsource rmspec test sign buildroot target buildarch buildos \
|
--clean --rmsource --rmspec --test --sign --buildroot \
|
||||||
nobuild nodeps nodirtokens' ${cur_nodash#-} ) )
|
--targetbuildarch --buildos --nobuild --nodeps --nodirtokens' \
|
||||||
dashify
|
-- $cur ) )
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
if [[ ${COMP_WORDS[1]} == -b* ]]; then
|
if [[ ${COMP_WORDS[1]} == -b* ]]; then
|
||||||
@ -828,15 +807,14 @@ _rpm()
|
|||||||
;;
|
;;
|
||||||
--re@(build|compile))
|
--re@(build|compile))
|
||||||
_expand || return 0
|
_expand || return 0
|
||||||
COMPREPLY=( $( compgen -W 'nodeps rmsource rmspec sign \
|
COMPREPLY=( $( compgen -W '--nodeps --rmsource --rmspec \
|
||||||
nodirtokens' ${cur_nodash#-} ) )
|
--sign --nodirtokens' -- $cur ) )
|
||||||
dashify
|
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# complete on source RPMs
|
# complete on source RPMs
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( compgen -f -X '!*.src.rpm' \
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -f -X '!*.src.rpm' -- \
|
||||||
$cur ) )
|
$cur ) )
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d $cur ) )
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--tarbuild)
|
--tarbuild)
|
||||||
@ -855,9 +833,8 @@ _rpm()
|
|||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--@(clean|rms@(ource|pec)))
|
--@(clean|rms@(ource|pec)))
|
||||||
COMPREPLY=( $( compgen -W 'clean rmsource rmspec' \
|
COMPREPLY=( $( compgen -W '--clean --rmsource --rmspec' -- \
|
||||||
${cur_nodash#-} ) )
|
$cur ) )
|
||||||
dashify
|
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
file_glob spec
|
file_glob spec
|
||||||
|
Loading…
x
Reference in New Issue
Block a user