diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:24:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:24:05 +0000 |
commit | cf1b401909b5e54edfd80656b1a18eaa31f9f6f1 (patch) | |
tree | edb0ffff2a43d84ba9b4c862b394cfeeebb36ddc /utils/bash-autocomplete.sh | |
parent | ef915aab0ac566c55bfb0d7a9f6635bb5d94d4af (diff) |
Notes
Diffstat (limited to 'utils/bash-autocomplete.sh')
-rwxr-xr-x | utils/bash-autocomplete.sh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/utils/bash-autocomplete.sh b/utils/bash-autocomplete.sh index ba908bcc0bc3..775b1f45351a 100755 --- a/utils/bash-autocomplete.sh +++ b/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,14 @@ _clang() arg="$w2=,$cur" fi - local flags=$( clang --autocomplete="$arg" ) + flags=$( "${COMP_WORDS[0]}" --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 |