summaryrefslogtreecommitdiff
path: root/completions/bash
diff options
context:
space:
mode:
Diffstat (limited to 'completions/bash')
-rw-r--r--completions/bash/apt17
1 files changed, 8 insertions, 9 deletions
diff --git a/completions/bash/apt b/completions/bash/apt
index 4c3ccbc7e..35716e7a7 100644
--- a/completions/bash/apt
+++ b/completions/bash/apt
@@ -69,7 +69,7 @@ _apt()
# supported options per command
if [[ "$cur" == -* ]]; then
- case $command in
+ case ${command-} in
install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove)
COMPREPLY=( $( compgen -W '--show-progress
--fix-broken --purge --verbose-versions --auto-remove
@@ -170,7 +170,7 @@ _apt()
fi
# specific command arguments
- if [[ -n $command ]]; then
+ if [[ -v command ]]; then
case $command in
remove|purge|autoremove)
if [[ -f /etc/debian_version ]]; then
@@ -189,10 +189,11 @@ _apt()
return 0
;;
install)
- COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
- 2> /dev/null ) )
- if [[ "$cur" == ./* || "$cur" == /* ]]; then
+ if [[ "$cur" == .* || "$cur" == /* || "$cur" == ~* ]]; then
_filedir "deb"
+ else
+ COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+ 2> /dev/null ) )
fi
return 0
;;
@@ -217,10 +218,8 @@ _apt()
return 0
;;
esac
- fi
-
- # no command yet, show what commands we have
- if [ "$command" = "" ]; then
+ else
+ # no command yet, show what commands we have
COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
fi