I had no problem with temp files per se - it was just a TOCTTOU race as
Dana explained well.
I also like Bart's alternative. That patch applied, compiled, and ran
fine. I did strace it and the trace looks fine as it should from the
C source. gettempfile seems more sound than gettempname.
Out of curiosity, I also strace'd `zsh -fc ': =(echo 1)'`. That showed
O_EXCL also, though it seems there is a maybe no longer needed stat()?
I didn't look into the C. Maybe a minor optimization opportunity.
Anyway, attached is an updated patch with Dana's approach in all 3 spots,
but with ':' as delimiter-delimiter rather than Dana's '<' '>' since ':'
is what the man page uses for that splitting expansion flag. It seems
to work fine for me, but someone else should maybe give it a try.
Also, it may not matter, but on that, there seems to be a special rule
for space itself and `bindkey " "` formats as `" "-value` which breaks
both old and new parses, giving a 3-element array. E.g.:
bindkey ' ' | IFS=$' \t' read -A x; for e in $x;echo $e