From Paul Ackersviller on Sun, 05 Mar 2000
Your comparison of ksh versus bash neglected to mention zsh, which does have co-processes, but using a different syntax than ksh. It can be made to emulate ksh in many regards, but in general puts it to shame (especially for interactive use).
-- Paul Ackersviller
Guilty as charged. I did wonder as I was writing that whether there would be a zsh fan our there to correct me.
I don't use zsh, though I've seen that it has some cool features. I didn't know if it supported co-processes, and I didn't have the time to find out last month.
However, I did issue a quick 'apt-get install zsh' command as a result of your message. (I was curious what syntax it DOES use).
Hmmm... Okay! I see.
Here's an example of the zsh co-routine syntax:
print -p 4 + 5
read -p answer
The only difference is the 'coproc' keyword instead of the '|&' operator from ksh. I see that the >&p and <&p redirection operators work exactly as they do under ksh.
I also see that the zsh co-processes seem to have the same limitations as their Korn shell ancestors. The ones that come immediately to mind are:
- Only one co-process at a time (per shell).
- No way to do non-blocking I/O on the co-process
However, I can see where most programmers would say that asking for these features is really gilding the lily.