1

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

1 Answer 1

0

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 :-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .