Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] _java: fix completion when $CLASSPATH contains empty entries



Treat them as a . instead of a / as this is what java does.
---

jure_ on #zsh noticed that zsh took very long to complete class names, turns out
he had a trailing : in his $CLASSPATH. A quick test shows that java treats these
as a ., not a /, though this does not appear to be documented anywhere.

 Completion/Unix/Type/_java_class |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Type/_java_class b/Completion/Unix/Type/_java_class
index d81669c..0201288 100644
--- a/Completion/Unix/Type/_java_class
+++ b/Completion/Unix/Type/_java_class
@@ -13,9 +13,10 @@ classpath="${${classpath[2]:-${CLASSPATH:-.}}//\\:/:}"
 : "$classpath[@]"

 for i in "${(s.:.)classpath}"; do
-  if [ -f $i ] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
+  [[ -z $i ]] && i=.
+  if [[ -f $i ]] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
     c+=( ${${${(M)$(_call_program jar_classes jar -tf
$i)##*.class}%%.class}:gs#/#.#} )
-  elif [ -d $i ]; then
+  elif [[ -d $i ]]; then
     c+=( $i/**/*.class(.:r:s/.class//:s#$i/##:gs#/#.#) )
   fi
 done
-- 



-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author