a52f674
From 1bb3ed6816bf287d2cd30bd5b2c7b97786cd65c8 Mon Sep 17 00:00:00 2001
ca73a27
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
ca73a27
Date: Thu, 6 Feb 2014 00:31:22 -0500
ca73a27
Subject: [PATCH] bash-completion: fix completion of complete verbs
ca73a27
ca73a27
When doing 'command verb<TAB>', the arguments for verb would be
ca73a27
proposed, but it is too early. We should complete verb first.
ca73a27
ca73a27
https://bugs.freedesktop.org/show_bug.cgi?id=74596
a52f674
(cherry picked from commit 3ce09b7da2eb8b888066468663b2b5c81a05a03c)
ca73a27
ca73a27
Conflicts:
ca73a27
	shell-completion/bash/busctl
ca73a27
	shell-completion/bash/loginctl
ca73a27
	shell-completion/bash/systemctl
ca73a27
	shell-completion/bash/systemd-analyze
ca73a27
---
ca73a27
 shell-completion/bash/hostnamectl     | 2 +-
ca73a27
 shell-completion/bash/localectl       | 2 +-
ca73a27
 shell-completion/bash/loginctl        | 2 +-
ca73a27
 shell-completion/bash/systemctl       | 2 +-
ca73a27
 shell-completion/bash/systemd-analyze | 2 +-
ca73a27
 shell-completion/bash/timedatectl     | 2 +-
ca73a27
 shell-completion/bash/udevadm         | 2 +-
ca73a27
 7 files changed, 7 insertions(+), 7 deletions(-)
ca73a27
ca73a27
diff --git a/shell-completion/bash/hostnamectl b/shell-completion/bash/hostnamectl
ca73a27
index 38ab134..9c75da9 100644
ca73a27
--- a/shell-completion/bash/hostnamectl
ca73a27
+++ b/shell-completion/bash/hostnamectl
ca73a27
@@ -41,7 +41,7 @@ _hostnamectl() {
ca73a27
                       [NAME]='set-hostname'
ca73a27
         )
ca73a27
 
ca73a27
-        for ((i=0; i <= COMP_CWORD; i++)); do
ca73a27
+        for ((i=0; i < COMP_CWORD; i++)); do
ca73a27
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
ca73a27
                         verb=${COMP_WORDS[i]}
ca73a27
                         break
ca73a27
diff --git a/shell-completion/bash/localectl b/shell-completion/bash/localectl
ca73a27
index bec9e78..84e2a6b 100644
ca73a27
--- a/shell-completion/bash/localectl
ca73a27
+++ b/shell-completion/bash/localectl
ca73a27
@@ -52,7 +52,7 @@ _localectl() {
ca73a27
                       [X11]='set-x11-keymap'
ca73a27
         )
ca73a27
 
ca73a27
-        for ((i=0; i <= COMP_CWORD; i++)); do
ca73a27
+        for ((i=0; i < COMP_CWORD; i++)); do
ca73a27
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
ca73a27
                         verb=${COMP_WORDS[i]}
ca73a27
                         break
ca73a27
diff --git a/shell-completion/bash/loginctl b/shell-completion/bash/loginctl
ca73a27
index 3104b30..26a8696 100644
ca73a27
--- a/shell-completion/bash/loginctl
ca73a27
+++ b/shell-completion/bash/loginctl
ca73a27
@@ -70,7 +70,7 @@ _loginctl () {
ca73a27
                 [ATTACH]='attach'
ca73a27
         )
ca73a27
 
ca73a27
-        for ((i=0; $i <= $COMP_CWORD; i++)); do
ca73a27
+        for ((i=0; i < COMP_CWORD; i++)); do
ca73a27
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
ca73a27
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
ca73a27
                         verb=${COMP_WORDS[i]}
ca73a27
diff --git a/shell-completion/bash/systemctl b/shell-completion/bash/systemctl
ca73a27
index 84149e3..a5f10b4 100644
ca73a27
--- a/shell-completion/bash/systemctl
ca73a27
+++ b/shell-completion/bash/systemctl
ca73a27
@@ -146,7 +146,7 @@ _systemctl () {
ca73a27
                   [TARGETS]='set-default'
ca73a27
         )
ca73a27
 
ca73a27
-        for ((i=0; $i <= $COMP_CWORD; i++)); do
ca73a27
+        for ((i=0; i < COMP_CWORD; i++)); do
ca73a27
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
ca73a27
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
ca73a27
                         verb=${COMP_WORDS[i]}
ca73a27
diff --git a/shell-completion/bash/systemd-analyze b/shell-completion/bash/systemd-analyze
ca73a27
index b65466b..6afcd96 100644
ca73a27
--- a/shell-completion/bash/systemd-analyze
ca73a27
+++ b/shell-completion/bash/systemd-analyze
ca73a27
@@ -39,7 +39,7 @@ _systemd_analyze() {
ca73a27
 
ca73a27
         _init_completion || return
ca73a27
 
ca73a27
-        for ((i=0; $i <= $COMP_CWORD; i++)); do
ca73a27
+        for ((i=0; i < COMP_CWORD; i++)); do
ca73a27
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
ca73a27
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
ca73a27
                         verb=${COMP_WORDS[i]}
ca73a27
diff --git a/shell-completion/bash/timedatectl b/shell-completion/bash/timedatectl
ca73a27
index c6a6545..1a0acc6 100644
ca73a27
--- a/shell-completion/bash/timedatectl
ca73a27
+++ b/shell-completion/bash/timedatectl
ca73a27
@@ -52,7 +52,7 @@ _timedatectl() {
ca73a27
                      [TIME]='set-time'
ca73a27
         )
ca73a27
 
ca73a27
-        for ((i=0; i <= COMP_CWORD; i++)); do
ca73a27
+        for ((i=0; i < COMP_CWORD; i++)); do
ca73a27
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
ca73a27
                         verb=${COMP_WORDS[i]}
ca73a27
                         break
ca73a27
diff --git a/shell-completion/bash/udevadm b/shell-completion/bash/udevadm
ca73a27
index 8ad8550..7e89189 100644
ca73a27
--- a/shell-completion/bash/udevadm
ca73a27
+++ b/shell-completion/bash/udevadm
ca73a27
@@ -36,7 +36,7 @@ _udevadm() {
ca73a27
 
ca73a27
         local verbs=(info trigger settle control monitor hwdb test-builtin test)
ca73a27
 
ca73a27
-        for ((i=0; i <= COMP_CWORD; i++)); do
ca73a27
+        for ((i=0; i < COMP_CWORD; i++)); do
ca73a27
                 if __contains_word "${COMP_WORDS[i]}" "${verbs[@]}" &&
ca73a27
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
ca73a27
                         verb=${COMP_WORDS[i]}