zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: fix for df completion
@ 2023-09-26 21:08 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2023-09-26 21:08 UTC (permalink / raw)
  To: Zsh workers

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;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-26 21:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-26 21:08 PATCH: fix for df completion Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).