From 9018c27ba414869008400d7b11f811cbac6a3ff8 Mon Sep 17 00:00:00 2001 From: lspitzner Date: Sun, 3 Apr 2016 00:05:27 +0200 Subject: [PATCH] Fix bash-completion after "--" #3272 accidentally disabled completions at the start of flags, e.g. on "cabal install --". [CI SKIP] --- cabal-install/bash-completion/cabal | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cabal-install/bash-completion/cabal b/cabal-install/bash-completion/cabal index 36d7feee61d..985399b86ce 100644 --- a/cabal-install/bash-completion/cabal +++ b/cabal-install/bash-completion/cabal @@ -55,11 +55,16 @@ _cabal_subcommands() __cabal_has_doubledash () { - for w in "${COMP_WORDS[@]}" - do - if [ "--" == "$w" ]; then + local c=1 + # Ignore the last word, because it is replaced anyways. + # This allows expansion for flags on "cabal foo --", + # but does not try to complete after "cabal foo -- ". + local n=$((${#COMP_WORDS[@]} - 1)) + while [ $c -lt $n ]; do + if [ "--" = "${COMP_WORDS[c]}" ]; then return 0 fi + ((c++)) done return 1 }