[PATCH] D34594: [GSoC] Delete space after flags which has '=' prefix

Yuka Takahashi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 24 06:55:54 PDT 2017


yamaguchi created this revision.

This is patch for bash completion for clang project.
We don't need `=` when completing options like "-stdlib=".


https://reviews.llvm.org/D34594

Files:
  clang/utils/bash-autocomplete.sh


Index: clang/utils/bash-autocomplete.sh
===================================================================
--- clang/utils/bash-autocomplete.sh
+++ clang/utils/bash-autocomplete.sh
@@ -1,7 +1,7 @@
 # Please add "source /path/to/bash-autocomplete.sh" to your .bashrc to use this.
 _clang()
 {
-  local cur prev words cword arg
+  local cur prev words cword arg=""
   _init_completion -n : || return
 
   # bash always separates '=' as a token even if there's no space before/after '='.
@@ -22,16 +22,17 @@
   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
+    if [[ ${flags: -1} == '=' ]]; then
+      compopt -o nospace
+    fi
     COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) )
   fi
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34594.103838.patch
Type: text/x-patch
Size: 1032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170624/3c28937f/attachment.bin>


More information about the llvm-commits mailing list