-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement async_worker_eval to affect environment inside worker #29
Conversation
Haha, thanks @maximbaz 😄. |
I can't test this at the moment, but I'd say everything looks good to me. I wanted to implement this too but was too worried about getting tripped up by strange shell expansions. |
Thanks for the feedback @maximbaz and @annacrombie.
I feel ya 😄! At least this uses much of the same code path as I'll go ahead and release this, please report back if you run into any issues! |
@mafredri, I finally got around to testing this, and just a little thing I noticed: The cat coproc is spawned before the eval occurs so cat does not inherit the environment, which isn't acceptable for my use case. I easily got around this by just reorganizing the code a little as you can see here. I wonder if this messes anything else up, or perhaps it is only me who would need this behaviour. Anyways I thought I would let you know. |
@annacrombie ah yes, sorry, I had forgotten about that detail with regards to your use case (pwd of deepest process). I'm curious, using this branch, do you run into the issue easily or is it rare? Even with 60fa536 I imagine the issue should still present itself, at least with long-running async tasks. The coproc will be running for as long as there is a async job running, meaning that even with your proposed fix, the pwd of the coproc would not be updated. As an alternate solution, would it suffice to issue If we also included your patch, then the order would not matter |
As soon as I updated, I was noticing this problem. With 60fa536, the issue was partially fixed, the first change of directory would be propogated but future changes were not. This was happening wether or not I did |
@annacrombie thanks for the detailed explanation. Looking at this again, and your patches, I have a potential fix for you that I could merge in if it works (it's more correct anyway). What I think is happening is that each diff --git a/async.zsh b/async.zsh
index d35f128..fb2ff81 100644
--- a/async.zsh
+++ b/async.zsh
@@ -198,6 +198,7 @@ _async_worker() {
shift cmd # Strip _async_eval from cmd.
_async_eval $cmd
do_eval=0
+ child_exit # Manually trigger after eval (exit coproc).
else
# Run job in background, completed jobs are printed to stdout.
_async_job $cmd & |
Based on #27 by @annacrombie.
Closes #25.
Closes #27.