summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2022-02-22 16:35:02 +0000
committerJulian Andres Klode <jak@debian.org>2022-02-22 16:35:02 +0000
commit647847769adca37a0b036c64cc0fad06b49bd99c (patch)
treef85b18b4f342ecef9c3a7828e79b737fe752f304
parent3834826b1628f9a7d5540c69aeb7d311faaf02c2 (diff)
parent19ffda1489858d132551a267fccdf7ab03b5e103 (diff)
Merge branch 'dont-bash-complete-pkgs-before-cmd' into 'main'
Don’t bash-complete package names before the command word See merge request apt-team/apt!221
-rw-r--r--completions/bash/apt9
1 files changed, 6 insertions, 3 deletions
diff --git a/completions/bash/apt b/completions/bash/apt
index b615c578f..59a8eaa94 100644
--- a/completions/bash/apt
+++ b/completions/bash/apt
@@ -52,7 +52,7 @@ _apt()
"policy")
local command i
- for (( i=0; i < ${#words[@]}-1; i++ )); do
+ for (( i=1; i < ${#words[@]}; i++ )); do
if [[ " ${COMMANDS[*]} " == *" ${words[i]} "* ]]; then
command=${words[i]}
break
@@ -67,8 +67,9 @@ _apt()
;;
esac
- # supported options per command
- if [[ "$cur" == -* ]]; then
+ # When the cursor (cword) is before the command word (i), only suggest
+ # options but not package or file names:
+ if [[ $cur == -* || ( -v command && $cword -le $i ) ]]; then
case ${command-} in
install|reinstall|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove|autopurge)
COMPREPLY=( $( compgen -W '--show-progress
@@ -167,6 +168,8 @@ _apt()
return 0
;;
esac
+
+ return
fi
# specific command arguments