completion for gcc and back-ends (g++, c++, g77, and gcj) from
Phil Edwards <phil@jaj.com>
This commit is contained in:
parent
3f4b69ac53
commit
318d304194
@ -1,6 +1,6 @@
|
||||
# bash_completion - some programmable completion functions for bash 2.05a
|
||||
#
|
||||
# $Id: bash_completion,v 1.118 2002/02/15 07:18:22 ianmacd Exp $
|
||||
# $Id: bash_completion,v 1.119 2002/02/15 23:53:58 ianmacd Exp $
|
||||
#
|
||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||
#
|
||||
@ -1719,6 +1719,62 @@ _psql ()
|
||||
}
|
||||
[ "$have" ] && complete -F _psql psql
|
||||
|
||||
# gcc(1) completion by Phil Edwards <phil@jaj.com>
|
||||
#
|
||||
# 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
|
||||
# tools (linker, assembler, preprocessor, etc) without any indication that
|
||||
# you cannot feed such options to the gcc driver directly. (For example, the
|
||||
# linker takes a -z option, but you must type -Wl,-z for gcc.) Instead, we
|
||||
# ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
|
||||
# --help output of the compiler.
|
||||
#
|
||||
have gcc &&
|
||||
_gcc()
|
||||
{
|
||||
local cc gcc backend
|
||||
|
||||
case "$2" in
|
||||
-*)
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$1" in
|
||||
\~*)
|
||||
eval gcc=$1
|
||||
;;
|
||||
*)
|
||||
gcc="$1"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$gcc" in
|
||||
gcj)
|
||||
backend=jc1
|
||||
;;
|
||||
*77)
|
||||
backend=f771
|
||||
;;
|
||||
*)
|
||||
backend=cc1 # [near-]universal backend
|
||||
;;
|
||||
esac
|
||||
|
||||
cc=$( $gcc -print-prog-name=$backend )
|
||||
|
||||
# sink stderr:
|
||||
# for C/C++/ObjectiveC it's useless
|
||||
# for FORTRAN/Java it's an error
|
||||
COMPREPLY=( $( $cc --help 2>/dev/null | tr '\t' ' ' | \
|
||||
sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
|
||||
grep ^"$2" | sort -u ) )
|
||||
}
|
||||
[ "$have" ] && complete -o default -F _gcc gcc g++ c++ g77 gcj
|
||||
[ $OS = Linux ] && complete -o default -F _gcc cc
|
||||
|
||||
# bash alias completion
|
||||
#
|
||||
_alias()
|
||||
|
Loading…
x
Reference in New Issue
Block a user