Closed jubishop closed 5 years ago
ok mb it works if i do ./example.zsh
instead of source example.zsh
it works! can you maybe enlighten me on what the difference is here? i'm used to using them interchnageably...
Hey @jubishop,
there's quite a significant difference between the two, actually. In the first case ./example.zsh
the script is run, think of it like running a completely separate program. In the second, using source
you're also running the script but you're running it as part of your current shell, and any changes it does will also become part of your shell. There's also other changes in behavior between run and source, for example, if you source a script that says exit 0
it will exit your whole shell and you have to start a new one, vs if you run that same script, it will only exit the script and return to your shell.
The example is meant to be run as a separate program so that it can make changes to its own environment without affecting your shell, this is why source
won't work.
I've removed my .zshrc entirely to ensure I have nothing conflicting or causing problems.
Then I:
and that prints
ok ./async_test.zsh 5.426s
but if I copy the entirety of the example script into
example.zsh
then:it just prints "Waiting..." endlessly and never completes. When I terminate it with ctrl-C at that point it actually prints
but if I don't terminate it, those items never print.
I've tried many tests of my own and see the same results, just figured I'd offer as a repo the example itself.
I'm using zsh 5.7.1, all other aspects of zsh seem to work fine for me.
thanks for any help!