break part of _gcc() into _longopt() and use this for ldd, wget, bash, id and

info completion, as demonstrated by Manu Rouat <emmanuel.rouat@wanadoo.fr>
This commit is contained in:
ianmacd 2002-02-16 00:13:00 +00:00
parent 318d304194
commit bacf3a3e4c

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05a
#
# $Id: bash_completion,v 1.119 2002/02/15 23:53:58 ianmacd Exp $
# $Id: bash_completion,v 1.120 2002/02/16 01:13:00 ianmacd Exp $
#
# Copyright (C) Ian Macdonald <ian@caliban.org>
#
@ -1719,6 +1719,34 @@ _psql ()
}
[ "$have" ] && complete -F _psql psql
_longopt()
{
case "$2" in
-*)
;;
*)
return 0
;;
esac
case "$1" in
\~*)
eval cmd=$1
;;
*)
cmd="$1"
;;
esac
[ "$4" = no_completion ] && return 0
COMPREPLY=( $( "$cmd" --help | sed -e '/--/!d' \
-e 's/.*--\([^ ]*\).*/--\1/'| \
grep ^"$2" | sort -u ) )
unset cmd
}
complete -o default -F _longopt ldd wget bash id info
# gcc(1) completion by Phil Edwards <phil@jaj.com>
#
# The only unusual feature is that we don't parse "gcc --help -v" output
@ -1732,26 +1760,13 @@ _psql ()
have gcc &&
_gcc()
{
local cc gcc backend
local cc cmd backend
case "$2" in
-*)
;;
*)
return
;;
esac
[[ "$2" != -* ]] && return 0
case "$1" in
\~*)
eval gcc=$1
;;
*)
gcc="$1"
;;
esac
_longopt "$1" "$2" "" no_completion
case "$gcc" in
case "$cmd" in
gcj)
backend=jc1
;;
@ -1763,7 +1778,7 @@ _gcc()
;;
esac
cc=$( $gcc -print-prog-name=$backend )
cc=$( $cmd -print-prog-name=$backend )
# sink stderr:
# for C/C++/ObjectiveC it's useless