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