# Open co-process co_process_program |& while read -p output do if ((input_required == true)) then input="just do some work"; print -p $input; fi if [[ $output = +(*done*) ]] then input="do something else"; print -p $input; fi if [[ $output = +(*finished*) ]] then input="time to go"; print -p $input; break; fi done