[PATCH] D34607: [Bash-autocompletion] Check clang version in Bash
Yuka Takahashi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 25 18:17:14 PDT 2017
yamaguchi created this revision.
Add check if user's clang version supports --autocomplete or not.
If not, we just autocomplete files.
https://reviews.llvm.org/D34607
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 flags
_init_completion -n : || return
# bash always separates '=' as a token even if there's no space before/after '='.
@@ -24,7 +24,12 @@
arg="$w2=,$cur"
fi
- local flags=$( clang --autocomplete="$arg" )
+ flags=$( clang --autocomplete="$arg" 2>/dev/null )
+ # Check if --autocomplete is supported in user's clang version.
+ if [[ "$?" != 0 ]]; then
+ _filedir
+ return 0
+ fi
if [[ "$cur" == '=' ]]; then
COMPREPLY=( $( compgen -W "$flags" -- "") )
elif [[ "$flags" == "" || "$arg" == "" ]]; then
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34607.103881.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170626/91c824a8/attachment.bin>
More information about the cfe-commits
mailing list