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

Spare some words on coproc implementation? Builtin like coproc?



Hello,
I wanted to use coproc's source in my own builtin because it has a
very flexible method of providing Zsh script code. But it turned out
coproc is a reserved-word, not a builtin. I suspect that issuing
coproc and then code (the very code, i.e. braces, subshells, ifs,
loops, etc.) works like if a single segment of code was provided –
coproc gets a word-code byte and just precedes its associated supplied
code which is unaffected and also compiled. This would point that
coproc is implemented in exec.c. Is this correct?

Would it be possible that a builtin (not a reserved-word), say
`mycoproc', would obtain Zsh script code normally through argv
argument in the builtin function prototype, join this argv array with
spaces to obtain single string, and then e.g. pass it to exec_simple
(plus a fork, somehow)? I think that this:

coproc for i in 1 2 3; do echo $i; done

will differ from this:

mycoproc for i in 1 2 3; do echo $i; done

because in the second case the $i will be expanded before running the
loop. So looks like no way out actually?

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin



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