r306555 - [Bash-autocompletion] Check clang version in Bash
Yuka Takahashi via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 28 08:59:55 PDT 2017
Author: yamaguchi
Date: Wed Jun 28 08:59:55 2017
New Revision: 306555
URL: http://llvm.org/viewvc/llvm-project?rev=306555&view=rev
Log:
[Bash-autocompletion] Check clang version in Bash
Summary:
Add check if user's clang version supports --autocomplete or not.
If not, we just autocomplete files.
Reviewers: ruiu, v.g.vassilev, teemperor
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D34607
Modified:
cfe/trunk/utils/bash-autocomplete.sh
Modified: cfe/trunk/utils/bash-autocomplete.sh
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=306555&r1=306554&r2=306555&view=diff
==============================================================================
--- cfe/trunk/utils/bash-autocomplete.sh (original)
+++ cfe/trunk/utils/bash-autocomplete.sh Wed Jun 28 08:59:55 2017
@@ -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 flags
_init_completion -n : || return
# bash always separates '=' as a token even if there's no space before/after '='.
@@ -24,7 +24,14 @@ _clang()
arg="$w2=,$cur"
fi
- local flags=$( clang --autocomplete="$arg" )
+ flags=$( clang --autocomplete="$arg" 2>/dev/null )
+ # If clang is old that it does not support --autocomplete,
+ # fall back to the filename completion.
+ if [[ "$?" != 0 ]]; then
+ _filedir
+ return
+ fi
+
if [[ "$cur" == '=' ]]; then
COMPREPLY=( $( compgen -W "$flags" -- "") )
elif [[ "$flags" == "" || "$arg" == "" ]]; then
More information about the cfe-commits
mailing list