Score:1

zsh completion ( compctl ) does not trig for command names containing dashes

cn flag

I've used zsh compctl since forever (late 90s or early 00s) but strangly never run into this before. I realized today when I intended to make some compctl config for update-alternatives that my completions where not trigged at all, it just used my standard fallback completion (files) ... so a very stripped down simple example to show the problem:

This works fine:

zshprompt% compctl -k '(arg1 arg2 arg3)' nodash

# typing 'nodash ' and hitting [Tab] once:
zshprompt% nodash arg

# hitting [Tab again]
zshprompt% nodash arg
arg1  arg2  arg3

But this complete files instead:

# just showing the current dir for reference:
zshprompt% ls .
file2.txt  myfile1.txt

zshprompt% compctl -k '(arg1 arg2 arg3)' with-dash

# typing 'with-dash ' and hitting [Tab] once:
zshprompt% with-dash 
file2.txt    myfile1.txt

As seen, the standard completion (listing current directory) is used rather than the one I added with compctl ...

I couldn't really find anything about this in the manpage (man zshcompctl) or online ... so does somebody, please, have an idea on how to get compctl match commands with dashes in the name?

TIA

Score:1
cn flag

Got it confirmed in the [email protected] mailing-list that this is a bug and got a suggested patch:

--- zsh-5.9.orig/Src/Zle/zle_tricky.c
+++ zsh-5.9/Src/Zle/zle_tricky.c
@@ -1315,6 +1315,8 @@ get_comp_string(void)
        ins = (tok == REPEAT ? 2 : (tok != STRING && tok != TYPESET));
        zsfree(cmdstr);
        cmdstr = ztrdup(tokstr);
+       untokenize(cmdstr);
+       remnulargs(cmdstr);
        cmdtok = tok;
        /*
         * If everything before is a redirection, or anything

I've tested it by applying the change as a quilt patch to the Debian zsh_5.9-4 source package rebuilt and installed it ... and it resolved my problem.

I will continue to run it now and if it does not seem to break anything else I will make sure it's applied in zsh upstream expecting it to eventually trinkle down to all different distributions.

If you have the problem now, and can't wait on it to trinkle down your distribuiton, download the zsh 5.9.4 source and patch it with the above patch and build it locally. If you want it integrated in you distribution packet here's how to do it for Debian (should work for most deb-package based distributions):

sudo apt install devscripts libcap-dev libelf-dev libgdbm-dev cm-super-minimal texinfo yodl quilt
mkdir /tmp/zsh_5.9
cd /tmp/zsh_5.9
apt source zsh=5.9-4
/bin/echo -e "1317a1318,1319\n> \t    untokenize(cmdstr);\n> \t    remnulargs(cmdstr);" > compctl-dash.diff
cd zsh-5.9
export QUILT_PATCHES=debian/patches 
export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" 
quilt push -a
quilt new compctl-dash.diff
quilt add Src/Zle/zle_tricky.c
patch Src/Zle/zle_tricky.c ../compctl-dash.diff
quilt refresh
quilt pop -a
debuild -b -uc -us
sudo dpkg -i ../zsh_5.9-4_amd64.deb

Hopefully this will be fixed upstream and have reached your distribution before the package is updated next, otherwise you will have to repeat it (or lock the zsh package version) until it is :-)

djdomi avatar
za flag
remember that you need to accept your answer if it was solved
frax avatar
cn flag
thx @djdomi ... I'll new in this forum, will accept it ... once I find out how to :-D
djdomi avatar
za flag
usually near your answer is a arrow like symbol
frax avatar
cn flag
ahhhh ... missed it completely it was a check-mark left of my answer, thx again @djdomi
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.