On Fri, May 17, 2024 at 11:58 AM Ray Andrews wrote: > On 2024-05-17 08:40, Mark J. Reed wrote: > > Functions are great, and I recommend using them - just use them _inside_ > the script. For anything but the most trivial scripts I make the main body > of the script a function, too, something like this: > > #!/usr/bin/env zsh > main() { > main program code here > } > > Just remember the *main "$@"* at the bottom, otherwise you've got a script that just declares some functions and exits without calling them. :) > 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. > Indeed. As a point of comparison, over the years I've written about a thousand little personal utility scripts that live in my ~/bin directory. I've only accumulated about 50 functions. -- Mark J. Reed