summaryrefslogtreecommitdiffstats
path: root/completions/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'completions/gcc')
-rw-r--r--completions/gcc56
1 files changed, 29 insertions, 27 deletions
diff --git a/completions/gcc b/completions/gcc
index fa95274..ed5bc9b 100644
--- a/completions/gcc
+++ b/completions/gcc
@@ -1,26 +1,26 @@
# gcc(1) completion -*- shell-script -*-
-_gcc()
+_comp_cmd_gcc()
{
- local cur prev prev2 words cword argument prefix prefix_length
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# Test that GCC is recent enough and if not fallback to
# parsing of --completion option.
- if ! $1 --completion=" " 2>/dev/null; then
+ if ! "$1" --completion=" " 2>/dev/null; then
if [[ $cur == -* ]]; then
- local cc=$($1 -print-prog-name=cc1 2>/dev/null)
+ local cc=$("$1" -print-prog-name=cc1 2>/dev/null)
[[ $cc ]] || return
- COMPREPLY=($(compgen -W "$($cc --help 2>/dev/null | tr '\t' ' ' |
- command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$cc" --help 2>/dev/null | tr '\t' ' ' |
+ command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/')"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir
+ _comp_compgen_filedir
fi
return
fi
+ local prev2 argument="" prefix prefix_length
# extract also for situations like: -fsanitize=add
if ((cword > 2)); then
prev2="${COMP_WORDS[cword - 2]}"
@@ -44,32 +44,34 @@ _gcc()
prefix="$prev "
fi
- if [[ ! -v argument ]]; then
- _filedir
+ if [[ ! $argument ]]; then
+ _comp_compgen_filedir
else
# In situation like '-fsanitize=add' $cur is equal to last token.
# Thus we need to strip the beginning of suggested option.
prefix_length=$((${#prefix} + 1))
- local flags=$($1 --completion="$argument" | cut -c $prefix_length-)
+ local flags=$("$1" --completion="$argument" | cut -c $prefix_length-)
[[ ${flags} == "=*" ]] && compopt -o nospace 2>/dev/null
- COMPREPLY=($(compgen -W "$flags" -- ""))
+ _comp_compgen -R -- -W "$flags"
fi
} &&
- complete -F _gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \
+ complete -F _comp_cmd_gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \
gccgo{,-5,-6,-7,-8} gcj gfortran{,-5,-6,-7,-8} gpc &&
+ _comp_cmd_gcc__setup_cmd()
{
- cc --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand cc) == *gcc* ]] &&
- complete -F _gcc cc || complete -F _minimal cc
- c++ --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand c++) == *g++* ]] &&
- complete -F _gcc c++ || complete -F _minimal c++
- f77 --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand f77) == *gfortran* ]] &&
- complete -F _gcc f77 || complete -F _minimal f77
- f95 --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand f95) == *gfortran* ]] &&
- complete -F _gcc f95 || complete -F _minimal f95
- }
+ local REPLY
+ _comp_realcommand "$1"
+ if [[ $REPLY == *$2* ]] ||
+ "$1" --version 2>/dev/null | command grep -q GCC; then
+ complete -F _comp_cmd_gcc "$1"
+ else
+ complete -F _comp_complete_minimal "$1"
+ fi
+ } &&
+ _comp_cmd_gcc__setup_cmd cc gcc &&
+ _comp_cmd_gcc__setup_cmd c++ g++ &&
+ _comp_cmd_gcc__setup_cmd f77 gfortran &&
+ _comp_cmd_gcc__setup_cmd f95 gfortran &&
+ unset -f _comp_cmd_gcc__setup_cmd
# ex: filetype=sh