- _rpm(): removed some superfluous returns

- _apt-cache(): renamed _apt_cache and caught some potential compgen errors
- _apt-get(): renamed _apt_get and caught some potential compgen errors
This commit is contained in:
ianmacd 2002-02-27 00:24:04 +00:00
parent f0af45516a
commit 2d0f63f8b3

View File

@ -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.152 2002/02/27 01:14:52 ianmacd Exp $ # $Id: bash_completion,v 1.153 2002/02/27 01:24:04 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -722,7 +722,6 @@ _rpm()
[[ "$cur" == -* ]] && return 0 [[ "$cur" == -* ]] && return 0
# add a list of RPMS to possible completions # add a list of RPMS to possible completions
file_glob rpm file_glob rpm
return 0
;; ;;
-q*p*) -q*p*)
# complete on list of relevant options # complete on list of relevant options
@ -736,12 +735,10 @@ _rpm()
[[ "$cur" == -* ]] && return 0 [[ "$cur" == -* ]] && return 0
# add a list of RPMS to possible completions # add a list of RPMS to possible completions
file_glob rpm file_glob rpm
return 0
;; ;;
-*f) -*f)
# standard filename completion # standard filename completion
COMPREPLY=( $( compgen -f -- $cur ) ) COMPREPLY=( $( compgen -f -- $cur ) )
return 0
;; ;;
-@(e|-erase)) -@(e|-erase))
# complete on list of relevant options # complete on list of relevant options
@ -750,7 +747,6 @@ _rpm()
# return if $cur is an option # return if $cur is an option
[[ "$cur" == -* ]] && return 0 [[ "$cur" == -* ]] && return 0
add_package_list add_package_list
return 0
;; ;;
-q*) -q*)
# complete on list of relevant options # complete on list of relevant options
@ -767,7 +763,6 @@ _rpm()
# don't complete on packages if we are querying all packages # don't complete on packages if we are querying all packages
[[ ${COMP_WORDS[1]} == -qa* ]] && return 0 [[ ${COMP_WORDS[1]} == -qa* ]] && return 0
add_package_list add_package_list
return 0
;; ;;
-@(K|-checksig)) -@(K|-checksig))
# complete on list of relevant options # complete on list of relevant options
@ -776,7 +771,6 @@ _rpm()
[[ "$cur" == -* ]] && return 0 [[ "$cur" == -* ]] && return 0
# add a list of RPMS to possible completions # add a list of RPMS to possible completions
file_glob rpm file_glob rpm
return 0
;; ;;
-@([Vy]*|-verify)) -@([Vy]*|-verify))
# complete on list of relevant options # complete on list of relevant options
@ -785,7 +779,6 @@ _rpm()
# return if $cur is an option # return if $cur is an option
[[ "$cur" == -* ]] && return 0 [[ "$cur" == -* ]] && return 0
add_package_list add_package_list
return 0
;; ;;
-[bt]*) -[bt]*)
# complete on list of relevant options # complete on list of relevant options
@ -803,7 +796,6 @@ _rpm()
# complete on .tar files # complete on .tar files
file_glob '@(tgz|tar.@(gz|bz2))' file_glob '@(tgz|tar.@(gz|bz2))'
fi fi
return 0
;; ;;
--re@(build|compile)) --re@(build|compile))
_expand || return 0 _expand || return 0
@ -815,22 +807,18 @@ _rpm()
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
;; ;;
--tarbuild) --tarbuild)
_expand || return 0 _expand || return 0
# complete on tarred sources # complete on tarred sources
file_glob '@(tgz|tar.@(gz|bz2))' file_glob '@(tgz|tar.@(gz|bz2))'
return 0
;; ;;
--@(re|add)sign) --@(re|add)sign)
# complete on RPMs # complete on RPMs
file_glob rpm file_glob rpm
return 0
;; ;;
--set@(perms|gids)) --set@(perms|gids))
add_package_list add_package_list
return 0
;; ;;
--@(clean|rms@(ource|pec))) --@(clean|rms@(ource|pec)))
COMPREPLY=( $( compgen -W '--clean --rmsource --rmspec' -- \ COMPREPLY=( $( compgen -W '--clean --rmsource --rmspec' -- \
@ -838,7 +826,6 @@ _rpm()
# return if $cur is an option # return if $cur is an option
[[ "$cur" == -* ]] && return 0 [[ "$cur" == -* ]] && return 0
file_glob spec file_glob spec
return 0
;; ;;
-*g) -*g)
# package group completion # package group completion
@ -850,7 +837,6 @@ _rpm()
# backslash escape spaces and translate newlines to tabs # backslash escape spaces and translate newlines to tabs
COMPREPLY=( $( echo ${COMPREPLY[@]} | sed 's/ /\\ /g' | \ COMPREPLY=( $( echo ${COMPREPLY[@]} | sed 's/ /\\ /g' | \
tr '\n' '\t' ) ) tr '\n' '\t' ) )
return 0
;; ;;
esac esac
@ -861,7 +847,7 @@ _rpm()
# Debian Linux apt-get(8) completion. # Debian Linux apt-get(8) completion.
# #
have apt-get && have apt-get &&
_apt-get() _apt_get()
{ {
local cur prev special i local cur prev special i
@ -884,7 +870,7 @@ _apt-get()
fi fi
if [[ "$prev" == -*c ]] || [ "$prev" = --config-file ]; then if [[ "$prev" == -*c ]] || [ "$prev" = --config-file ]; then
COMPREPLY=( $( compgen -f $cur ) ) COMPREPLY=( $( compgen -f -- $cur ) )
else else
COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \ COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
dist-upgrade install remove source check \ dist-upgrade install remove source check \
@ -898,18 +884,17 @@ _apt-get()
--no-upgrade --force-yes --print-uris \ --no-upgrade --force-yes --print-uris \
--purge --reinstall --list-cleanup \ --purge --reinstall --list-cleanup \
--trivial-only --no-remove --diff-only \ --trivial-only --no-remove --diff-only \
--tar-only --config-file --option ' | \ --tar-only --config-file --option' -- $cur ) )
grep ^$cur ) )
fi fi
return 0 return 0
} }
[ "$have" ] && complete -F _apt-get -o filenames apt-get [ "$have" ] && complete -F _apt_get -o filenames apt-get
# Debian Linux apt-cache(8) completion. # Debian Linux apt-cache(8) completion.
# #
have apt-cache && have apt-cache &&
_apt-cache() _apt_cache()
{ {
local cur prev special i local cur prev special i
@ -926,7 +911,7 @@ _apt-cache()
if [ -n "$special" ]; then if [ -n "$special" ]; then
case $special in case $special in
add) add)
COMPREPLY=( $( compgen -f $cur ) ) COMPREPLY=( $( compgen -f -- $cur ) )
return 0 return 0
;; ;;
show?(pkg)|depends|dotty) show?(pkg)|depends|dotty)
@ -938,7 +923,7 @@ _apt-cache()
if [[ "$prev" == -*c ]] || [ "$prev" = --config-file ]; then if [[ "$prev" == -*c ]] || [ "$prev" = --config-file ]; then
COMPREPLY=( $( compgen -f $cur ) ) COMPREPLY=( $( compgen -f -- $cur ) )
else else
COMPREPLY=( $( compgen -W 'add gencaches showpkg stats dump \ COMPREPLY=( $( compgen -W 'add gencaches showpkg stats dump \
dumpavail unmet check search show dotty \ dumpavail unmet check search show dotty \
@ -946,13 +931,13 @@ _apt-cache()
-o --help --version --pkg-cache --src-cache \ -o --help --version --pkg-cache --src-cache \
--quiet --important --full --all-versions \ --quiet --important --full --all-versions \
--no-generate --names-only --all-names \ --no-generate --names-only --all-names \
--config-file --option' | grep ^$cur ) ) --config-file --option' -- $cur ) )
fi fi
return 0 return 0
} }
[ "$have" ] && complete -F _apt-cache -o filenames apt-cache [ "$have" ] && complete -F _apt-cache -o filenames apt-cache
complete -F _apt-cache -o filenames apt-cache complete -F _apt_cache -o filenames apt-cache
# chsh(1) completion # chsh(1) completion
# #