Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: exit to shell from nested function calls.
On Fri, May 17, 2024 at 8:58 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> On 2024-05-17 08:40, Mark J. Reed wrote:
>
> Only define functions inside your interactive shell when they need to make changes that persist after they exit - like changing directories, or updating variable values, etc.
>
> That would limit their number considerably. Ok, goodbye functions
Well, don't take the wrong lesson from this. There are other reasons
to use functions in an interactive shell. Aside from functions being
the only way to create custom ZLE actions (widgets), they are the best
way to implement simple repetitive tasks that don't need the overhead
of forking, and the only way to isolate temporary variables while
retaining access to globals that are not exported.
It's more a matter of determining which tasks are discrete. If you're
writing something that needs neither to access nor to modify the state
of the interactive shell, make it a script first, then think about
whether it's simple enough to become a function.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author