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

PATCH: fix for df completion



When trying to complete options after df, the initial - is just removed.
I narrowed this down to a minimal function to reproduce the problem and
it relates to the use of both -M and -U to compadd in _canonical_paths.
The -M actually comes from _umountable. Matchers have no meaning when
-U is used - all strings are added as matches. The patch below is to
the compadd builtin option handling. If -U was specified, it simply
ignores all matching controls from -M options. This does mean that with
-U, invalid matchers won't produce errors. There must be an underlying
problem down in addmatches() where it should be ignoring dat->match and
the matchers linked list if CAF_MATCH is not set. I'm fine with it if
someone wants to track down this bad logic in the matching code. The
approach below does at least fix df completion and this approach saves
the completion code from having to do quite a big of pointless work.

_umountable also generates some bogus completions on FreeBSD for
automount maps and an empty entry that comes from appending an array to
a variable declared as a scalar. That results in an initial empty array
element.

Oliver

diff --git a/Completion/Unix/Type/_umountable b/Completion/Unix/Type/_umountable
index 6e4988e2d..0111555b6 100644
--- a/Completion/Unix/Type/_umountable
+++ b/Completion/Unix/Type/_umountable
@@ -1,6 +1,6 @@
 #autoload
 local tmp
-local dev_tmp dpath_tmp mp_tmp mline
+local -a dev_tmp dpath_tmp mp_tmp mline
 
 case "$OSTYPE" in
 linux*)
@@ -15,6 +15,7 @@ irix*)
   ;;
 freebsd*|dragonfly*)
   /sbin/mount | while read mline; do
+    [[ $mline[(w)1] = map ]] && continue
     dev_tmp+=( $mline[(w)1] )
     mp_tmp+=( $mline[(w)3] )
   done
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 96ad7b3f1..342611f1f 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -829,7 +829,9 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 
  ca_args:
 
-    if (mstr && (match = parse_cmatcher(name, mstr)) == pcm_err) {
+    if (mstr && (dat.aflags & CAF_MATCH) &&
+	    (match = parse_cmatcher(name, mstr)) == pcm_err)
+    {
 	zsfree(mstr);
 	zfree(dat.dpar, dparsize);
 	return 1;





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