fix copy-packages in zsh

fixes #299...

My first attempt [#328] didn't work because of the change to using `local` vars. This one should solve that.