bash completion: avoid space after options taking an argument
authorGuido Günther <agx@sigxcpu.org>
Fri, 7 Jan 2011 08:54:10 +0000 (09:54 +0100)
committerGuido Günther <agx@sigxcpu.org>
Fri, 7 Jan 2011 08:58:16 +0000 (09:58 +0100)
This makes branch and tag completion more useful.

debian/git-buildpackage.bash-completion

index 57b2675..8c61170 100644 (file)
@@ -60,7 +60,12 @@ _gbp_comp ()
         return 0
     fi
 
-    COMPREPLY=($(compgen -W "$options" -- $cur))
+    # separate opts by tab so we can append a space to all options not ending
+    # with an equal sign
+    tab_opts=$(echo "$options" | sed -e 's/ \+/\t/g' -e 's/[^=]$/& /g')
+    type compopt &>/dev/null && compopt -o nospace
+    local IFS=$'\t\n'
+    COMPREPLY=($(compgen -W "$tab_opts" -- $cur))
 }