On 2024-05-17 10:36, Bart Schaefer wrote:
On Fri, May 17, 2024, 10:04 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
... make it a script first, then think about
whether it's simple enough to become a function.

Forgot to mention, you can also get the best of both worlds by writing a function with sections (up to even the whole function body) wrapped in subshell parens.
My whole project of trying to learn zsh 'as you go', was wrong from the start.  There are things like the above that can only be learned by instruction -- or by endless grief.  Need zsh classroom where the teacher knows what you need to know before you know you need to know it.  A very good book would be nice too.