- minor bug fixes to _make()

- multiple potential compgen error clean-ups
This commit is contained in:
ianmacd 2002-02-27 00:41:56 +00:00
parent 2d0f63f8b3
commit 128690832c

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05a # bash_completion - some programmable completion functions for bash 2.05a
# #
# $Id: bash_completion,v 1.153 2002/02/27 01:24:04 ianmacd Exp $ # $Id: bash_completion,v 1.154 2002/02/27 01:41:56 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -397,7 +397,7 @@ _killall()
# #
_find() _find()
{ {
local cur prev i local cur prev
COMPREPLY=() COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
@ -952,7 +952,7 @@ _chsh()
if [ "$prev" = "-s" ]; then if [ "$prev" = "-s" ]; then
COMPREPLY=( $( chsh -l | grep ^$cur ) ) COMPREPLY=( $( chsh -l | grep ^$cur ) )
else else
COMPREPLY=( $( compgen -u $cur ) ) COMPREPLY=( $( compgen -u -- $cur ) )
fi fi
return 0 return 0
@ -964,34 +964,31 @@ complete -F _chsh chsh
have chkconfig && have chkconfig &&
_chkconfig() _chkconfig()
{ {
local cur prev i local cur prev
COMPREPLY=() COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
cur_nodash=${cur#--}
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'list add del level' $cur_nodash ) ) COMPREPLY=( $( compgen -W '--list --add --del --level' -- \
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do $cur ) )
COMPREPLY[i]=--${COMPREPLY[i]}
done
return 0 return 0
fi fi
if [ $COMP_CWORD -eq 4 ]; then if [ $COMP_CWORD -eq 4 ]; then
COMPREPLY=( $( compgen -W 'on off reset' $cur ) ) COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) )
return 0 return 0
fi fi
case "$prev" in case "$prev" in
@([1-6]|--@(list|add|del))) @([1-6]|--@(list|add|del)))
COMPREPLY=( $( compgen -W "`(cd /etc/rc.d/init.d; echo *)`" \ COMPREPLY=( $( compgen -W "`(cd /etc/rc.d/init.d; echo *)`" \
$cur) ) -- $cur) )
return 0 return 0
;; ;;
--level) --level)
COMPREPLY=( $( compgen -W '1 2 3 4 5 6' $cur ) ) COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
return 0 return 0
;; ;;
esac esac
@ -1047,7 +1044,7 @@ _known_hosts()
done done
else else
# Just do normal hostname completion # Just do normal hostname completion
COMPREPLY=( $( compgen -A hostname -S "$suffix" $cur ) ) COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) )
fi fi
return 0 return 0
@ -1070,15 +1067,15 @@ _ssh()
case "$prev" in case "$prev" in
-*c) -*c)
COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \ COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
arcfour cast128-cbc' $cur ) ) arcfour cast128-cbc' -- $cur ) )
;; ;;
-*l) -*l)
COMPREPLY=( $( compgen -u $cur ) ) COMPREPLY=( $( compgen -u -- $cur ) )
;; ;;
*) *)
_known_hosts _known_hosts
[ $COMP_CWORD -eq 1 ] || \ [ $COMP_CWORD -eq 1 ] || \
COMPREPLY=( ${COMPREPLY[@]} $( compgen -c $cur ) ) COMPREPLY=( ${COMPREPLY[@]} $( compgen -c -- $cur ) )
esac esac
return 0 return 0
@ -1120,11 +1117,9 @@ _route()
return 0 return 0
fi fi
# Must use grep here, otherwise $cur will cause compgen to barf, if
# it begins with a hyphen
COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \ COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \
window irtt reject mod dyn reinstate dev' | \ window irtt reject mod dyn reinstate dev' \
grep ^$cur ) ) -- $cur ) )
COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \ COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
(while read -d ' ' i; do (while read -d ' ' i; do
@ -1158,13 +1153,14 @@ _make()
# we could be a little smarter here and return matches against # we could be a little smarter here and return matches against
# `makefile Makefile *.mk', whatever exists # `makefile Makefile *.mk', whatever exists
if [[ "$prev" == -*f ]]; then if [[ "$prev" == -*f ]]; then
COMPREPLY=( $( compgen -f $cur ) ) COMPREPLY=( $( compgen -f -- $cur ) )
return 0 return 0
fi fi
# if we want an option, return the possible posix options # if we want an option, return the possible posix options
if [[ "$cur" == - ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-e -f -i -k -n -p -q -r -S -s -t' | grep ^$cur ) ) COMPREPLY=( $( compgen -W '-e -f -i -k -n -p -q -r -S -s -t' -- \
$cur ) )
return 0 return 0
fi fi
@ -1181,7 +1177,7 @@ _make()
# with -f # with -f
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
if [[ ${COMP_WORDS[i]} == -*f ]]; then if [[ ${COMP_WORDS[i]} == -*f ]]; then
eval makef=${COMP_WORDS[i+1]} # eval for tilde expansion eval makef=${COMP_WORDS[i+1]} # eval for tilde expansion
break break
fi fi
done done
@ -1199,9 +1195,7 @@ _make()
eval $gcmd ) ) eval $gcmd ) )
# default to filename completion if all else failed # default to filename completion if all else failed
if [ ${#COMPREPLY[@]} -eq 0 ]; then [ ${#COMPREPLY[@]} -eq 0 ] && _filedir
COMPREPLY=( $( compgen -f $cur ) )
fi
return 0 return 0
} }