From f2c66fbe1f01b720741e0fe2bfa619ca2862a6b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Mon, 6 Feb 2017 17:08:35 +0100
Subject: [PATCH] bash completion: Complete subcommands for the current word.

* etc/completion/bash/guix (_guix_complete_subcommand): Refer to
the $COMP_CWORD element instead of the last element.
---
 etc/completion/bash/guix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
index 00c3dfaf49e..6a5f281c4fe 100644
--- a/etc/completion/bash/guix
+++ b/etc/completion/bash/guix
@@ -26,7 +26,7 @@ _guix_complete_subcommand ()
     local subcommands="$(${COMP_WORDS[0]} $command --help 2> /dev/null \
                          | grep '^   [a-z]' \
                          | sed -e's/^ \+\([a-z-]\+\).*$/\1/g')"
-    COMPREPLY=($(compgen -W "$subcommands" -- "${COMP_WORDS[${#COMP_WORDS[*]} - 1]}"))
+    COMPREPLY=($(compgen -W "$subcommands" -- "${COMP_WORDS[$COMP_CWORD]}"))
 }
 
 _guix_complete_available_package ()
-- 
GitLab