various fixes from Rafael Sepúlveda <drs@gnulinux.org.mx>

- fixed apt-cache 'show' completion bug
- fixed function names with hyphens
- aptitude completion function was loaded, regardless of presence of program
- various improvements to other Debian commands
This commit is contained in:
ianmacd 2002-10-13 01:46:49 +00:00
parent d1041d29dc
commit 046ad76d74

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05b # bash_completion - some programmable completion functions for bash 2.05b
# #
# $Id: bash_completion,v 1.436 2002/10/10 15:43:38 ianmacd Exp $ # $Id: bash_completion,v 1.437 2002/10/13 03:46:49 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -1446,10 +1446,6 @@ _apt_get()
if [ -n "$special" ]; then if [ -n "$special" ]; then
case $special in case $special in
@(install|source|build-dep))
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
;;
remove) remove)
if [ -f /etc/debian_version ]; then if [ -f /etc/debian_version ]; then
# Debian system # Debian system
@ -1461,6 +1457,11 @@ _apt_get()
fi fi
return 0 return 0
;; ;;
*)
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
;;
esac esac
fi fi
@ -1477,10 +1478,11 @@ _apt_get()
return 0 return 0
;; ;;
*) esac
COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
dist-upgrade install remove source build-dep \ if [[ "$cur" == -* ]]; then
check clean autoclean -d -f -h -v -m -q -s -y \
COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y \
-u -t -b -c -o --download-only --fix-broken \ -u -t -b -c -o --download-only --fix-broken \
--help --version --ignore-missing \ --help --version --ignore-missing \
--fix-missing --no-download --quiet --simulate \ --fix-missing --no-download --quiet --simulate \
@ -1492,8 +1494,14 @@ _apt_get()
--list-cleanup --default-release \ --list-cleanup --default-release \
--trivial-only --no-remove --diff-only \ --trivial-only --no-remove --diff-only \
--tar-only --config-file --option' -- $cur ) ) --tar-only --config-file --option' -- $cur ) )
;; else
esac
COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
dist-upgrade install remove source build-dep \
check clean autoclean' -- $cur ) )
fi
return 0 return 0
} }
@ -1511,11 +1519,14 @@ _apt_cache()
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
if [ "$cur" != show ]; then
for (( i=0; i < ${#COMP_WORDS}-1; i++ )); do for (( i=0; i < ${#COMP_WORDS}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(add|show?(pkg)|depends|dotty|policy) ]]; then if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|show?(pkg)) ]]; then
special=${COMP_WORDS[i]} special=${COMP_WORDS[i]}
fi fi
done done
fi
if [ -n "$special" ]; then if [ -n "$special" ]; then
case $special in case $special in
@ -1523,10 +1534,12 @@ _apt_cache()
_filedir _filedir
return 0 return 0
;; ;;
show?(pkg)|depends|dotty|policy)
COMPREPLY=( $( apt-cache pkgnames $cur 2>/dev/null) ) *)
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0 return 0
;; ;;
esac esac
fi fi
@ -1536,24 +1549,32 @@ _apt_cache()
_filedir _filedir
return 0 return 0
;; ;;
search)
return 0
;;
esac
*) if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W 'add gencaches showpkg stats dump \ COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \
dumpavail unmet check search show dotty policy \
depends pkgnames -h -v -p -s -q -i -f -a -g -c \
-o --help --version --pkg-cache --src-cache \ -o --help --version --pkg-cache --src-cache \
--quiet --important --full --all-versions \ --quiet --important --full --all-versions \
--generate --no-generate --names-only \ --generate --no-generate --names-only \
--all-names --config-file --option \ --all-names --config-file --option \
--recurse' -- $cur ) ) --recurse' -- $cur ) )
;; else
esac
COMPREPLY=( $( compgen -W 'add gencaches showpkg show stats \
dumpavail unmet check search dump dotty policy \
depends pkgnames' -- $cur ) )
fi
return 0 return 0
} }
[ "$have" ] && complete -F _apt-cache $filenames apt-cache [ "$have" ] && complete -F _apt_cache $filenames apt-cache
complete -F _apt_cache $filenames apt-cache
# Debian aptitude(1) completion # Debian aptitude(1) completion
# #
@ -1624,8 +1645,11 @@ _aptitude()
purge markauto unmarkauto dist-upgrade \ purge markauto unmarkauto dist-upgrade \
download search' -- $cur ) ) download search' -- $cur ) )
fi fi
return 0
} }
complete -F _aptitude $default aptitude [ "$have" ] && complete -F _aptitude $default aptitude
} }
# Debian apt-build(1) completion. # Debian apt-build(1) completion.
@ -1673,18 +1697,22 @@ _apt_build()
return 0 return 0
;; ;;
*) esac
COMPREPLY=( $( compgen -W "update upgrade install remove \
source dist-upgrade world clean info \ if [[ "$cur" == -* ]]; then
clean-repository update-repository \ COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \
--help --show-upgraded -u --build-dir \
--repository-dir --build-only \ --repository-dir --build-only \
--build-command --reinstall --rebuild \ --build-command --reinstall --rebuild \
--remove-builddep --no-wrapper --purge \ --remove-builddep --no-wrapper --purge \
--patch --patch-strip -p --yes -y \ --patch --patch-strip -p --yes -y \
--version -v --no-source" -- $cur ) ) --version -v --no-source' -- $cur ) )
;;
esac else
COMPREPLY=( $( compgen -W 'update upgrade install remove \
source dist-upgrade world clean info \
clean-repository update-repository ' -- $cur ) )
fi
return 0 return 0
} }
@ -2892,7 +2920,7 @@ complete -F _dpkg $filenames dpkg dpkg-deb
# Debian GNU dpkg-reconfigure(8) completion # Debian GNU dpkg-reconfigure(8) completion
# #
have dpkg-reconfigure && have dpkg-reconfigure &&
_dpkg-reconfigure() _dpkg_reconfigure()
{ {
local cur prev opt local cur prev opt
@ -2923,7 +2951,7 @@ _dpkg-reconfigure()
COMPREPLY=( $( _comp-dpkg-installed-packages $cur ) ) COMPREPLY=( $( _comp-dpkg-installed-packages $cur ) )
fi fi
} }
[ "$have" ] && complete -F _dpkg-reconfigure $default dpkg-reconfigure [ "$have" ] && complete -F _dpkg_reconfigure $default dpkg-reconfigure
# Debian Linux dselect(8) completion. # Debian Linux dselect(8) completion.
# #
@ -2945,13 +2973,17 @@ _dselect()
_filedir _filedir
;; ;;
*)
COMPREPLY=( $( compgen -W 'access update select install \
config remove quit --admindir --help \
--version --licence --license --expert \
--debug' -- $cur ) )
;;
esac esac
COMPREPLY=( $( compgen -W -- $cur ) )
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--admindir --help --version --licence \
--license --expert --debug' -- $cur ) )
else
COMPREPLY=( $( compgen -W 'access update select install config \
remove quit' -- $cur ) )
fi
return 0 return 0
} }
@ -3670,7 +3702,7 @@ _python()
return 0 return 0
;; ;;
!(python|-?)) !(python|-?))
[[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W)) ]] && _filedir [[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir
;; ;;
esac esac