fixed _cd() so that if $CDPATH is set and no completions are returned

relative to its paths, we still attempt directory completion relative to $PWD
This commit is contained in:
ianmacd 2002-01-05 19:48:59 +00:00
parent 5dfe16ea34
commit e961f14f55

View File

@ -2,7 +2,7 @@
# #
# <![CDATA[ # <![CDATA[
# #
# $Id: bash_completion,v 1.45 2002/01/05 20:42:41 ianmacd Exp $ # $Id: bash_completion,v 1.46 2002/01/05 20:48:59 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -1253,7 +1253,10 @@ _cd()
fi fi
# standard dir completion if parameter starts with /, ./ or ../ # standard dir completion if parameter starts with /, ./ or ../
[[ "$cur" == ?(.)?(.)/* ]] && COMPREPLY=( $( compgen -d $cur ) ) && return 0 if [[ "$cur" == ?(.)?(.)/* ]]; then
COMPREPLY=( $( compgen -d $cur ) )
return 0
fi
if [ -n "$CDPATH" ]; then if [ -n "$CDPATH" ]; then
# we have a CDPATH, so loop on its contents # we have a CDPATH, so loop on its contents
for i in ${CDPATH//:/ }; do for i in ${CDPATH//:/ }; do
@ -1262,9 +1265,8 @@ _cd()
# add subdirs to list of completions as necessary # add subdirs to list of completions as necessary
[ ${#dirs[@]} ] && COMPREPLY=( ${COMPREPLY[@]} ${dirs[@]#$i/}) [ ${#dirs[@]} ] && COMPREPLY=( ${COMPREPLY[@]} ${dirs[@]#$i/})
done done
else
COMPREPLY=( $( compgen -d $cur ) )
fi fi
COMPREPLY=( $( compgen -d $cur ) )
return 0 return 0
} }