]> granicus.if.org Git - clang/commitdiff
[bash-autocompletion] Delete space after flags which has '=' prefix
authorYuka Takahashi <yukatkh@gmail.com>
Mon, 26 Jun 2017 00:35:36 +0000 (00:35 +0000)
committerYuka Takahashi <yukatkh@gmail.com>
Mon, 26 Jun 2017 00:35:36 +0000 (00:35 +0000)
Summary:
This is patch for bash completion for clang project.
We don't need space when completing options like "-stdlib=".

Differential Revision: https://reviews.llvm.org/D34594

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306258 91177308-0d34-0410-b5e6-96231b3b80d8

utils/bash-autocomplete.sh

index 3e9f65f10db2c6fcad16f18e7af6778328e0b7d1..ba908bcc0bc325b97470fbdfdc1d497d704ced5b 100644 (file)
@@ -22,16 +22,17 @@ _clang()
   elif [[ "$w2" == -* && "$w1" == '=' ]]; then
     # -foo=bar<tab>
     arg="$w2=,$cur"
-  else
-    _filedir
   fi
 
   local flags=$( clang --autocomplete="$arg" )
-  if [[ "$cur" == "=" ]]; then
+  if [[ "$cur" == '=' ]]; then
     COMPREPLY=( $( compgen -W "$flags" -- "") )
-  elif [[ "$flags" == "" ]]; then
+  elif [[ "$flags" == "" || "$arg" == "" ]]; then
     _filedir
   else
+    # Bash automatically appends a space after '=' by default.
+    # Disable it so that it works nicely for options in the form of -foo=bar.
+    [[ "${flags: -1}" == '=' ]] && compopt -o nospace
     COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) )
   fi
 }