Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

I/O to shell function in zsh coproc



I think this is a bug in zsh (4.3.10), I can't figure out what is wrong:

function wcFunc() {
  wc
}

# coproc wc : works with plain wc
coproc wcFunc
wcf=$!
# copy the write and read fd's for the coproc
exec 5>&p 6<&p
# start another null coproc to get a new target for the p fd
coproc exit
echo hi there >&5
# close the fd, so hopefully the coproc would exit, but it doesn't
exec 5>&-
# sleep $LONGTIME
# kill $wcf
var=$( cat <&6 )
echo $var

As noted, it works when I use plain wc, rather than wcFunc. Of course, it's a lot more useful if it would work with shell functions. It also works if you kill the coproc, but in the general case you'd need to first wait for the estimated time it takes for the coproc to complete, and you might not be at all sure how long it will take.

Thanks and regards,
Rory



Messages sorted by: Reverse Date, Date, Thread, Author