diff options
Diffstat (limited to 'completions/gcc')
-rw-r--r-- | completions/gcc | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/completions/gcc b/completions/gcc index d78e3e24..bafb81b7 100644 --- a/completions/gcc +++ b/completions/gcc @@ -1,4 +1,4 @@ -# gcc(1) completion +# gcc(1) completion -*- shell-script -*- # # The only unusual feature is that we don't parse "gcc --help -v" output # directly, because that would include the options of all the other backend @@ -8,16 +8,15 @@ # ask the driver ("g++") for the name of the compiler ("cc1"), and parse the # --help output of the compiler. -have gcc && _gcc() { - local cur cc backend - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return _expand || return 0 + local cc backend + case $1 in gcj) backend=jc1 @@ -34,7 +33,8 @@ _gcc() esac if [[ "$cur" == -* ]]; then - cc=$( $1 -print-prog-name=$backend ) + cc=$( $1 -print-prog-name=$backend 2>/dev/null ) + [[ $cc ]] || return # sink stderr: # for C/C++/ObjectiveC it's useless # for FORTRAN/Java it's an error @@ -47,13 +47,8 @@ _gcc() fi } && complete -F _gcc gcc g++ c++ g77 gcj gpc -[ $USERLAND = GNU -o $UNAME = Cygwin ] && \ -[ -n "${have:-}" ] && complete -F _gcc cc -# Local variables: -# mode: shell-script -# sh-basic-offset: 4 -# sh-indent-comment: t -# indent-tabs-mode: nil -# End: +[[ $OSTYPE == *cygwin* ]] || _userland GNU && _have gcc && \ + complete -F _gcc cc || : + # ex: ts=4 sw=4 et filetype=sh |