bash-completion: fix completion of complete verbs
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Feb 2014 05:31:22 +0000 (00:31 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Feb 2014 05:45:00 +0000 (00:45 -0500)
When doing 'command verb<TAB>', the arguments for verb would be
proposed, but it is too early. We should complete verb first.

https://bugs.freedesktop.org/show_bug.cgi?id=74596

shell-completion/bash/busctl
shell-completion/bash/hostnamectl
shell-completion/bash/localectl
shell-completion/bash/loginctl
shell-completion/bash/systemctl
shell-completion/bash/systemd-analyze
shell-completion/bash/timedatectl
shell-completion/bash/udevadm

index 8ce813f..7480a6c 100644 (file)
@@ -53,7 +53,7 @@ _busctl() {
                 [STANDALONE]='list monitor'
         )
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
                         verb=${COMP_WORDS[i]}
index 38ab134..9c75da9 100644 (file)
@@ -41,7 +41,7 @@ _hostnamectl() {
                       [NAME]='set-hostname'
         )
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
                         verb=${COMP_WORDS[i]}
                         break
index bec9e78..84e2a6b 100644 (file)
@@ -52,7 +52,7 @@ _localectl() {
                       [X11]='set-x11-keymap'
         )
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
                         verb=${COMP_WORDS[i]}
                         break
index 7263f7f..e7adb93 100644 (file)
@@ -70,7 +70,7 @@ _loginctl () {
                 [ATTACH]='attach'
         )
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
                         verb=${COMP_WORDS[i]}
index 232d2d6..dc7ef66 100644 (file)
@@ -146,7 +146,7 @@ _systemctl () {
                   [TARGETS]='set-default'
         )
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
                         verb=${COMP_WORDS[i]}
index 98c793b..6afcd96 100644 (file)
@@ -39,7 +39,7 @@ _systemd_analyze() {
 
         _init_completion || return
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
                         verb=${COMP_WORDS[i]}
index c6a6545..1a0acc6 100644 (file)
@@ -52,7 +52,7 @@ _timedatectl() {
                      [TIME]='set-time'
         )
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
                         verb=${COMP_WORDS[i]}
                         break
index d58cdf5..b828b8d 100644 (file)
@@ -36,7 +36,7 @@ _udevadm() {
 
         local verbs=(info trigger settle control monitor hwdb test-builtin test)
 
-        for ((i=0; i <= COMP_CWORD; i++)); do
+        for ((i=0; i < COMP_CWORD; i++)); do
                 if __contains_word "${COMP_WORDS[i]}" "${verbs[@]}" &&
                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
                         verb=${COMP_WORDS[i]}