This is a great question! This is what I really want to achieve, but donβt know how to do it (I appreciate if anyone can help me). This is useful not only for bash , but for all other knitr engines like python , ruby etc. The reason this does not work at the moment is that knitr runs the code through system('engine -arg code') , that is, for each piece of code, a new mechanism session is opened, so all the pieces are executed mainly in different processes.
Ideally, I need an engine that opens a session and continues to listen to the new code, but I'm not sure if this is possible at all. AFAIK, the only way to exchange variables is to write them to files, which is clearly inconvenient.
Yihui xie
source share