@@ -105,7 +105,7 @@ _comp_cmd_java__classes()
105
105
# available packages completion
106
106
_comp_cmd_java__packages ()
107
107
{
108
- local sourcepath i
108
+ local sourcepath i files
109
109
110
110
# find which sourcepath to use
111
111
_java_find_sourcepath
@@ -116,15 +116,17 @@ _comp_cmd_java__packages()
116
116
# parse each sourcepath element for packages
117
117
for i in " ${sourcepath[@]} " ; do
118
118
if [[ -d $i ]]; then
119
- COMPREPLY+=($( command ls -F -d " $i /$cur " * 2> /dev/null |
120
- command sed -e ' s|^' " $i " ' /||' ) )
119
+ _comp_expand_glob files ' "$i/$cur"*'
120
+ (( ${# files[@]} )) || continue
121
+ _comp_split -la COMPREPLY " $(
122
+ command ls -F -d " ${files[@]} " 2> /dev/null |
123
+ command sed -e ' s|^' " $i " ' /||'
124
+ ) "
121
125
fi
122
126
done
123
127
if (( ${# COMPREPLY[@]} != 0 )) ; then
124
- # keep only packages
125
- COMPREPLY=($( tr " " " \n" <<< " ${COMPREPLY[@]}" | command grep " /$" ) )
126
- # remove packages extension
127
- COMPREPLY=(${COMPREPLY[@]%/ } )
128
+ # keep only packages with the package suffix `/` being removed
129
+ _comp_split -l COMPREPLY " $( printf ' %s\n' " ${COMPREPLY[@]} " | command sed -n ' s,/$,,p' ) "
128
130
# convert path syntax to package syntax
129
131
cur=" ${COMPREPLY[*]// \/ / .} "
130
132
fi
0 commit comments