multiple potential causes of compgen errors removed

This commit is contained in:
ianmacd 2002-02-27 01:02:43 +00:00
parent 128690832c
commit 0f4d4d3dd4

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.154 2002/02/27 01:41:56 ianmacd Exp $ # $Id: bash_completion,v 1.155 2002/02/27 02:02:43 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -1219,11 +1219,13 @@ _service()
#[[ "$cur" == -* ]] && return 0 #[[ "$cur" == -* ]] && return 0
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W '`echo $sysvdir/!(*.rpmsave|*.rpmorig)`' ) ) COMPREPLY=( $( compgen -W '`echo $sysvdir/!(*.rpmsave|*.rpmorig)`' ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$sysvdir/}' $cur ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$sysvdir/}' -- \
$cur ) )
else else
COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \ COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
s/^.*Usage.*{\(.*\)}.*$/\1/p" \ s/^.*Usage.*{\(.*\)}.*$/\1/p" \
$sysvdir/${COMP_WORDS[1]}`' $cur ) ) $sysvdir/${COMP_WORDS[1]}`' -- \
$cur ) )
fi fi
return 0 return 0
@ -1246,16 +1248,16 @@ _tar()
_filedir _filedir
;; ;;
+([^zj])f) +([^zj])f)
COMPREPLY=( $( compgen -d $cur ) \ COMPREPLY=( $( compgen -d -- $cur ) \
$( compgen -f -X '!*.tar' $cur ) ) $( compgen -f -X '!*.tar' -- $cur ) )
;; ;;
*z*f) *z*f)
COMPREPLY=( $( compgen -d $cur ) \ COMPREPLY=( $( compgen -d -- $cur ) \
$( compgen -f -X '!*.t?(ar.)gz' $cur ) ) $( compgen -f -X '!*.t?(ar.)gz' -- $cur ) )
;; ;;
*j*f) *j*f)
COMPREPLY=( $( compgen -d $cur ) \ COMPREPLY=( $( compgen -d -- $cur ) \
$( compgen -f -X '!*.tar.bz2' $cur ) ) $( compgen -f -X '!*.tar.bz2' -- $cur ) )
;; ;;
*) *)
_filedir _filedir
@ -1289,26 +1291,26 @@ _iptables()
case "$prev" in case "$prev" in
-*[AIDPFXL]) -*[AIDPFXL])
COMPREPLY=( $( compgen -W '`iptables $table -nL | sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' $cur ) ) COMPREPLY=( $( compgen -W '`iptables $table -nL | sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ) )
;; ;;
-*t) -*t)
COMPREPLY=( $( compgen -W 'nat filter mangle' $cur ) ) COMPREPLY=( $( compgen -W 'nat filter mangle' -- $cur ) )
;; ;;
-j) -j)
if [ "$table" = "-t filter" -o "$table" = "" ]; then if [ "$table" = "-t filter" -o "$table" = "" ]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
`iptables $table -nL | sed -ne "$chain" \ `iptables $table -nL | sed -ne "$chain" \
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
$cur ) ) $cur ) )
elif [ "$table" = "-t nat" ]; then elif [ "$table" = "-t nat" ]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \ MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \
sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
$cur ) ) -- $cur ) )
elif [ "$table" = "-t mangle" ]; then elif [ "$table" = "-t mangle" ]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
MARK TOS `iptables $table -nL | sed -ne "$chain" \ MARK TOS `iptables $table -nL | sed -ne "$chain" \
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
$cur ) ) $cur ) )
fi fi
;; ;;
@ -1330,7 +1332,7 @@ _tcpdump()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W 'host net port src dst ether gateway \ COMPREPLY=( $( compgen -W 'host net port src dst ether gateway \
less greater' $cur ) ) less greater' -- $cur ) )
} }
[ "$have" ] && complete -F _tcpdump tcpdump [ "$have" ] && complete -F _tcpdump tcpdump
@ -1359,7 +1361,7 @@ _cd()
done done
fi fi
IFS=$' \t\n' IFS=$' \t\n'
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d $cur ) ) COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) )
return 0 return 0
} }
@ -1378,7 +1380,7 @@ _command()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -c $cur ) ) COMPREPLY=( $( compgen -c -- $cur ) )
elif complete -p ${COMP_WORDS[1]} &>/dev/null; then elif complete -p ${COMP_WORDS[1]} &>/dev/null; then
cspec=$( complete -p ${COMP_WORDS[1]} ) cspec=$( complete -p ${COMP_WORDS[1]} )
if [ "${cspec#*-F }" != "$cspec" ]; then if [ "${cspec#*-F }" != "$cspec" ]; then
@ -1402,15 +1404,15 @@ _command()
# complete -[abcdefgjkvu] # complete -[abcdefgjkvu]
func=$( echo $cspec | \ func=$( echo $cspec | \
sed -e 's/^.*\(-[abcdefgjkvu]\).*$/\1/' ) sed -e 's/^.*\(-[abcdefgjkvu]\).*$/\1/' )
COMPREPLY=( $( compgen $func $cur ) ) COMPREPLY=( $( compgen $func -- $cur ) )
elif [ "${cspec#*-A}" != "$cspec" ]; then elif [ "${cspec#*-A}" != "$cspec" ]; then
# complete -A <type> # complete -A <type>
func=${cspec#*-A } func=${cspec#*-A }
func=${func%% *} func=${func%% *}
COMPREPLY=( $( compgen -A $func $cur ) ) COMPREPLY=( $( compgen -A $func -- $cur ) )
fi fi
else else
COMPREPLY=( $( compgen -f $cur ) ) COMPREPLY=( $( compgen -f -- $cur ) )
fi fi
} }
complete -F _command -o filenames nohup exec nice eval strace sudo complete -F _command -o filenames nohup exec nice eval strace sudo
@ -1425,7 +1427,7 @@ _root_command()
} }
complete -F _command -o filenames sudo complete -F _command -o filenames sudo
# Basic Perforce completion by Frank Cusack (frank@google.com) # Perforce completion by Frank Cusack (frank@google.com)
# #
have p4 && have p4 &&
_p4() _p4()
@ -1450,16 +1452,16 @@ _p4()
text binary resource" text binary resource"
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W "$p4commands" $cur ) ) COMPREPLY=( $( compgen -W "$p4commands" -- $cur ) )
elif [ $COMP_CWORD -eq 2 ]; then elif [ $COMP_CWORD -eq 2 ]; then
case "$prev" in case "$prev" in
help) help)
COMPREPLY=( $( compgen -W "simple commands \ COMPREPLY=( $( compgen -W "simple commands \
environment filetypes jobview revisions \ environment filetypes jobview revisions \
usage views $p4commands" $cur ) ) usage views $p4commands" -- $cur ) )
;; ;;
admin) admin)
COMPREPLY=( $( compgen -W "checkpoint stop" $cur ) ) COMPREPLY=( $( compgen -W "checkpoint stop" -- $cur ) )
;; ;;
*) *)
;; ;;
@ -1470,7 +1472,8 @@ _p4()
-t) -t)
case "$prev2" in case "$prev2" in
add|edit|reopen) add|edit|reopen)
COMPREPLY=( $(compgen -W "$p4filetypes" $cur) ) COMPREPLY=( $( compgen -W "$p4filetypes" \
-- $cur) )
;; ;;
*) *)
;; ;;
@ -1516,7 +1519,7 @@ _nslookup()
COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= \ COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= \
srchlist= defname search port= querytype= \ srchlist= defname search port= querytype= \
type= recurse retry root timeout vc \ type= recurse retry root timeout vc \
ignoretc' $cur ) ) ignoretc' -- $cur ) )
} }
[ "$have" ] && complete -F _nslookup nslookup [ "$have" ] && complete -F _nslookup nslookup
@ -1533,22 +1536,23 @@ _mysqladmin()
case "$prev" in case "$prev" in
-u) -u)
COMPREPLY=( $( compgen -u $cur ) ) COMPREPLY=( $( compgen -u -- $cur ) )
return 0 return 0
;; ;;
*) *)
;; ;;
esac esac
COMPREPLY=( $( compgen -P '-' -W '# f ? C h p P i r E s S t u \ COMPREPLY=( $( compgen -W '-# -f -? -C -h -p -P -i -r -E -s -S -t -u \
v V w' ${cur#-} ) ) -v -V -w' -- $cur ) )
COMPREPLY=( ${COMPREPLY[@]} \ COMPREPLY=( ${COMPREPLY[@]} \
$( compgen -W 'create drop extended-status flush-hosts \ $( compgen -W 'create drop extended-status flush-hosts \
flush-logs flush-status flush-tables \ flush-logs flush-status flush-tables \
flush-threads flush-privileges kill \ flush-threads flush-privileges kill \
password ping processlist reload refresh \ password ping processlist reload refresh \
shutdown status variables version' $cur ) ) shutdown status variables version' \
-- $cur ) )
} }
[ "$have" ] && complete -F _mysqladmin mysqladmin [ "$have" ] && complete -F _mysqladmin mysqladmin
@ -1570,7 +1574,8 @@ _zip()
_expand || return 0 _expand || return 0
COMPREPLY=( $( compgen -f -X "$xspec" $cur ) $( compgen -d $cur ) ) COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
$( compgen -d -- $cur ) )
} }
[ "$have" ] && complete -F _zip -o filenames gzip bzip2 [ "$have" ] && complete -F _zip -o filenames gzip bzip2
@ -1596,7 +1601,7 @@ _openssl()
des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc \ des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc \
des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \ des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb \ rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb \
rc4 rc4-40' $cur ) ) rc4 rc4-40' -- $cur ) )
fi fi
return 0 return 0
@ -1647,7 +1652,7 @@ _ncftp()
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then
COMPREPLY=( $( compgen -W '`cut --output-delimiter " " \ COMPREPLY=( $( compgen -W '`cut --output-delimiter " " \
-s -f1-2 -d, ~/.ncftp/bookmarks`' $cur ) ) -s -f1-2 -d, ~/.ncftp/bookmarks`' -- $cur ) )
fi fi
return 0 return 0
@ -1666,7 +1671,7 @@ _gdb()
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 -c $cur ) ) COMPREPLY=( $( compgen -c -- $cur ) )
elif [ $COMP_CWORD -eq 2 ]; then elif [ $COMP_CWORD -eq 2 ]; then
COMPREPLY=( ${COMPREPLY[@]} $( ps ahx | sed -e 's#[]\[()]##g' |\ COMPREPLY=( ${COMPREPLY[@]} $( ps ahx | sed -e 's#[]\[()]##g' |\
awk '{p=$5;sub("^.*/","",p); \ awk '{p=$5;sub("^.*/","",p); \
@ -1695,7 +1700,8 @@ _psql()
-U) -U)
COMPREPLY=( $( psql -qtc 'select usename from pg_user' \ COMPREPLY=( $( psql -qtc 'select usename from pg_user' \
2>/dev/null | grep "^ $cur" ) ) 2>/dev/null | grep "^ $cur" ) )
[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u $cur ) ) [ ${#COMPREPLY[@]} -eq 0 ] && \
COMPREPLY=( $( compgen -u -- $cur ) )
return 0 return 0
;; ;;
*) *)
@ -1803,7 +1809,7 @@ _cardctl ()
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'status config ident suspend \ COMPREPLY=( $( compgen -W 'status config ident suspend \
resume reset eject insert scheme' \ resume reset eject insert scheme' \
$cur ) ) -- $cur ) )
fi fi
} }
[ "$have" ] && complete -F _cardctl cardctl [ "$have" ] && complete -F _cardctl cardctl
@ -1819,7 +1825,7 @@ _alias()
case "$COMP_LINE" in case "$COMP_LINE" in
*[^=]) *[^=])
COMPREPLY=( $( compgen -A alias -S '=' $cur ) ) COMPREPLY=( $( compgen -A alias -S '=' -- $cur ) )
;; ;;
*=) *=)
COMPREPLY=( "$( alias ${cur%=} | \ COMPREPLY=( "$( alias ${cur%=} | \
@ -1840,7 +1846,7 @@ _export()
case "$COMP_LINE" in case "$COMP_LINE" in
*[^=]) *[^=])
COMPREPLY=( $( compgen -v -S '=' $cur ) ) COMPREPLY=( $( compgen -v -S '=' -- $cur ) )
;; ;;
*=) *=)
COMPREPLY=( $( eval echo $`echo ${cur%=}` ) ) COMPREPLY=( $( eval echo $`echo ${cur%=}` ) )
@ -1859,7 +1865,7 @@ _function()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -A function $cur ) ) COMPREPLY=( $(compgen -A function -- $cur ) )
else else
COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" ) COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
fi fi