summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörn-Thorben Hinz <11910-jth@users.noreply.salsa.debian.org>2022-02-01 14:04:53 +0100
committerJörn-Thorben Hinz <11910-jth@users.noreply.salsa.debian.org>2022-02-01 14:13:07 +0100
commit783138b5bbeb36f4de09ab77bbef7c6f7f7234c6 (patch)
tree79aca420ff99f2e5e82b12569f0487738ba559f9
parent0251ed0b4f01b2813c31af9e5cbfe57dad61340d (diff)
Don’t fail bash-completion for `apt` when the nounset option is set
Following a practice from upstream bash-completion. See for example https://github.com/scop/bash-completion/commit/b807460140aa6dda09eb2af2ecf3afa1971c84c4
-rw-r--r--completions/bash/apt10
1 files changed, 4 insertions, 6 deletions
diff --git a/completions/bash/apt b/completions/bash/apt
index 90b4ef20c..3a6b0682f 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
@@ -214,10 +214,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