From df7ca94009cea17cdf06f48b4462984578c2038c Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 22 Jun 2021 14:54:08 +0100 Subject: [PATCH 1/3] completion/hostnamectl: do not dereference non-existing OPTS[ARGUNKNOWN] --- shell-completion/bash/hostnamectl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell-completion/bash/hostnamectl b/shell-completion/bash/hostnamectl index af4339111e..0f69e23e6f 100644 --- a/shell-completion/bash/hostnamectl +++ b/shell-completion/bash/hostnamectl @@ -39,7 +39,7 @@ _hostnamectl() { [ARG]='-H --host -M --machine --json' ) - if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then + if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --host|-H) comps=$(compgen -A hostname) From 6a0667d2b6f05682c2ced1b53132274049b9ea5c Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 22 Jun 2021 14:55:22 +0100 Subject: [PATCH 2/3] completion/systemd-delta,-resolve: autocomplete with parameters --- shell-completion/bash/systemd-delta | 2 +- shell-completion/bash/systemd-resolve | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell-completion/bash/systemd-delta b/shell-completion/bash/systemd-delta index f97b6dd5b2..1a24dc0710 100644 --- a/shell-completion/bash/systemd-delta +++ b/shell-completion/bash/systemd-delta @@ -48,7 +48,7 @@ _systemd-delta() { return 0 fi - if [[ "$cur" = -* ]]; then + if [[ "$cur" = -* ]] || [[ -z ${comps-} ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi diff --git a/shell-completion/bash/systemd-resolve b/shell-completion/bash/systemd-resolve index ec43948278..b165010b85 100644 --- a/shell-completion/bash/systemd-resolve +++ b/shell-completion/bash/systemd-resolve @@ -71,7 +71,7 @@ _systemd-resolve() { return 0 fi - if [[ "$cur" = -* ]]; then + if [[ "$cur" = -* ]] || [[ -z ${comps-} ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi From 36ec026830c6978be8bd39f3c6d1d7822495e07f Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 22 Jun 2021 14:56:19 +0100 Subject: [PATCH 3/3] completion: fix 'unbound variables' errors Fixes https://github.com/systemd/systemd/issues/19987 --- shell-completion/bash/bootctl | 2 +- shell-completion/bash/busctl | 2 +- shell-completion/bash/coredumpctl | 2 +- shell-completion/bash/homectl | 2 +- shell-completion/bash/hostnamectl | 2 +- shell-completion/bash/localectl | 2 +- shell-completion/bash/loginctl | 2 +- shell-completion/bash/machinectl | 2 +- shell-completion/bash/networkctl | 2 +- shell-completion/bash/portablectl | 2 +- shell-completion/bash/resolvectl | 2 +- shell-completion/bash/systemctl.in | 2 +- shell-completion/bash/systemd-analyze | 4 ++-- shell-completion/bash/systemd-delta | 2 +- shell-completion/bash/systemd-id128 | 2 +- shell-completion/bash/timedatectl | 2 +- shell-completion/bash/udevadm | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/shell-completion/bash/bootctl b/shell-completion/bash/bootctl index 391fa67bfc..e61188fee9 100644 --- a/shell-completion/bash/bootctl +++ b/shell-completion/bash/bootctl @@ -69,7 +69,7 @@ _bootctl() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' diff --git a/shell-completion/bash/busctl b/shell-completion/bash/busctl index 5a4acd337f..1cc41d4618 100644 --- a/shell-completion/bash/busctl +++ b/shell-completion/bash/busctl @@ -140,7 +140,7 @@ _busctl() { n=$(($COMP_CWORD - $i)) - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' diff --git a/shell-completion/bash/coredumpctl b/shell-completion/bash/coredumpctl index 5fc11fdbd2..54b8572515 100644 --- a/shell-completion/bash/coredumpctl +++ b/shell-completion/bash/coredumpctl @@ -83,7 +83,7 @@ _coredumpctl() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then comps='' diff --git a/shell-completion/bash/homectl b/shell-completion/bash/homectl index fe909fbb41..f738bfb37f 100644 --- a/shell-completion/bash/homectl +++ b/shell-completion/bash/homectl @@ -170,7 +170,7 @@ _homectl() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[NAME]}; then comps=$(__get_homes) diff --git a/shell-completion/bash/hostnamectl b/shell-completion/bash/hostnamectl index 0f69e23e6f..6f1909b599 100644 --- a/shell-completion/bash/hostnamectl +++ b/shell-completion/bash/hostnamectl @@ -77,7 +77,7 @@ _hostnamectl() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[CHASSIS]}; then comps='desktop laptop convertible server tablet handset watch embedded vm container' diff --git a/shell-completion/bash/localectl b/shell-completion/bash/localectl index fa0f8fdca1..987ae34cc9 100644 --- a/shell-completion/bash/localectl +++ b/shell-completion/bash/localectl @@ -67,7 +67,7 @@ _localectl() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[VARIANTS]}; then comps=$(command localectl list-x11-keymap-layouts) diff --git a/shell-completion/bash/loginctl b/shell-completion/bash/loginctl index f94f191d89..2d03fcca3e 100644 --- a/shell-completion/bash/loginctl +++ b/shell-completion/bash/loginctl @@ -93,7 +93,7 @@ _loginctl () { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps="${VERBS[*]}" elif __contains_word "$verb" ${VERBS[SESSIONS]}; then diff --git a/shell-completion/bash/machinectl b/shell-completion/bash/machinectl index bc3a7889b3..0227167928 100644 --- a/shell-completion/bash/machinectl +++ b/shell-completion/bash/machinectl @@ -95,7 +95,7 @@ _machinectl() { return 0 fi - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then diff --git a/shell-completion/bash/networkctl b/shell-completion/bash/networkctl index 1e4d0a2aae..40ac13abf8 100644 --- a/shell-completion/bash/networkctl +++ b/shell-completion/bash/networkctl @@ -69,7 +69,7 @@ _networkctl() { return 0 fi - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' diff --git a/shell-completion/bash/portablectl b/shell-completion/bash/portablectl index e18d04c7ea..a0ccc733ad 100644 --- a/shell-completion/bash/portablectl +++ b/shell-completion/bash/portablectl @@ -79,7 +79,7 @@ _portablectl() { n=$(($COMP_CWORD - $i)) - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' diff --git a/shell-completion/bash/resolvectl b/shell-completion/bash/resolvectl index dae4330d4c..646a197a13 100644 --- a/shell-completion/bash/resolvectl +++ b/shell-completion/bash/resolvectl @@ -87,7 +87,7 @@ _resolvectl() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps="${VERBS[*]}" elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[DOMAIN]}; then diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index e6e6ca0d7e..b61f88b012 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -254,7 +254,7 @@ _systemctl () { cur_orig="$(printf '%q' $cur)" fi - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps="${VERBS[*]}" elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then diff --git a/shell-completion/bash/systemd-analyze b/shell-completion/bash/systemd-analyze index eded49b50e..36fcf432ff 100644 --- a/shell-completion/bash/systemd-analyze +++ b/shell-completion/bash/systemd-analyze @@ -93,12 +93,12 @@ _systemd_analyze() { return 0 fi - if [[ -z $verb && $cur = -* ]]; then + if [[ -z ${verb-} && $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then diff --git a/shell-completion/bash/systemd-delta b/shell-completion/bash/systemd-delta index 1a24dc0710..f94c128533 100644 --- a/shell-completion/bash/systemd-delta +++ b/shell-completion/bash/systemd-delta @@ -53,7 +53,7 @@ _systemd-delta() { return 0 fi - COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + COMPREPLY=( $(compgen -W '${comps-}' -- "$cur") ) return 0 } diff --git a/shell-completion/bash/systemd-id128 b/shell-completion/bash/systemd-id128 index 25110d1309..ad4731de18 100644 --- a/shell-completion/bash/systemd-id128 +++ b/shell-completion/bash/systemd-id128 @@ -61,7 +61,7 @@ _systemd_id128() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' diff --git a/shell-completion/bash/timedatectl b/shell-completion/bash/timedatectl index 3e72ce6655..29dc27b39c 100644 --- a/shell-completion/bash/timedatectl +++ b/shell-completion/bash/timedatectl @@ -76,7 +76,7 @@ _timedatectl() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[BOOLEAN]}; then comps='true false' diff --git a/shell-completion/bash/udevadm b/shell-completion/bash/udevadm index d2c325b868..81036f3588 100644 --- a/shell-completion/bash/udevadm +++ b/shell-completion/bash/udevadm @@ -73,7 +73,7 @@ _udevadm() { fi done - if [[ -z $verb ]]; then + if [[ -z ${verb-} ]]; then if [[ "$cur" = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[COMMON]} ${OPTS[DEBUG]}' -- "$cur") ) else