Rewrite CVS roots completion, add $CVSROOT and contents of CVS/Root.

Still works poorly because of the colons and -o default.
This commit is contained in:
Ville Skyttä 2009-12-28 23:03:24 +02:00
parent fcc305a11b
commit 0b13b03886

View File

@ -45,13 +45,13 @@ _cvs_kflags()
_cvs_roots() _cvs_roots()
{ {
# TODO: this works very poorly because of the colons local -a cvsroots
if [ -r ~/.cvspass ]; then cvsroots=( $CVSROOT )
# Ugly escaping because of bash treating ':' specially [ -r ~/.cvspass ] && \
# TODO: this ugly escaping doesn't help :P cvsroots=( "${cvsroots[@]}" $( awk '{ print $2 }' ~/.cvspass ) )
cvsroots=$( awk '{ print $2 }' ~/.cvspass | sed -e 's/:/\\:/g' ) [ -r CVS/Root ] && cvsroots=( "${cvsroots[@]}" $(cat CVS/Root) )
COMPREPLY=( $( compgen -W '$cvsroots' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${cvsroots[@]}' -- "$cur" ) )
fi __ltrim_colon_completions "$cur"
} }
_cvs() _cvs()
@ -60,8 +60,8 @@ _cvs()
local -a flags miss files entries changed newremoved local -a flags miss files entries changed newremoved
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword :`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=`_get_pword :`
count=0 count=0
for i in "${COMP_WORDS[@]}"; do for i in "${COMP_WORDS[@]}"; do
@ -263,6 +263,8 @@ _cvs()
fi fi
;; ;;
cvsroot) cvsroot)
# TODO: works poorly because of the colons and -o default,
# could we drop -o default? works ok without it in cvsps
_cvs_roots _cvs_roots
;; ;;
export) export)