mafredri / zsh-async

Because your terminal should be able to perform tasks asynchronously without external tools!
MIT License
771 stars 35 forks source link

Clarify ZSH 5.0.X support? #30

Closed robobenklein closed 6 years ago

robobenklein commented 6 years ago

I'm not quite sure what the legacy support for these old ZSH versions is.

I saw that 5.0.2 was being tested, so I guess I had made some assumption about it being compatible. (Then I looked at travis.)

Could a 'Limitation' be added to the readme to describe the fallback or lack of functionality on the old zsh versions?

My specific case involves async_worker_eval seemingly not working on 5.0.2.

robobenklein commented 6 years ago

Also, it appears that async_flush_jobs is not working as expected on 5.0.2:

callbackfunc() { echo "async eval: ${(j. \!\! .)@}" }
async eval: ; !! 127 !!  !! 0.0023519993 !! (eval):1: command not found: _killjobs !! 0
mafredri commented 6 years ago

Could you provide some code that fully reproduces the issue? This library should work on zsh 5.0.2, althought that version of zsh is very buggy (as is 5.0.8).

You might be interested in https://github.com/mafredri/zsh-async/issues/12.

robobenklein commented 6 years ago

It's some combination of my personal ZSH config and a new prompt theme that I'm developing.

Starting a pure zsh (zsh -f) and loading the theme works as intended, but loading it via my configs causes something to go wrong.

I am investigating to see if there's a zsh option that's set differently now. After that, I'll try going through the minimal additions debugging.

robobenklein commented 6 years ago

I think I've discovered it might be an incompatibility with zplugin on 5.0.X.

I'll bring this issue up over there.

robobenklein commented 6 years ago

If you want to see the problem in action:

docker run --rm -t -i robobenklein/home:trusty zsh -l
ZSH_THEME=p10k zsh

And debugging logging (with the async callback data) gets sent to /tmp/_P10K_DBG_OUT.log.

Docker image is of my personal configs and will install my experimental theme automatically.

mafredri commented 6 years ago

I tried your image and I'm pretty sure the problem is that IFS gets redefined once (or multiple times). Because of it, the newline will not be stripped during the read command in: https://github.com/mafredri/zsh-async/blob/5248bd85bf2c522ebfa2b8d18ee7bc736d10c791/async.zsh#L151

For example, it's not that _killjobs isn't found, it's that \n_killjobs doesn't match _killjobs, meaning the switch statement is passed and and we end up eval:ing \n_killjobs instead of calling killjobs inside the async worker.

robobenklein commented 6 years ago

Working now, thanks!