zsh: calling functions within functions



~1 min read


83 words

When you write shell functions, it is sometimes useful to call a different function (smaller functions are easier to comprehend). How do you do that though?

You can just call it!

Imagine two functions:

hello() {
    echo "Hello, world"

main() {
  echo "Running main..."
  echo "...Ending main"

Running main...
Hello, world
...Ending main

Depending on what hello does, you may want a Subshell instead.

See StackExchange on How to Call A Function Inside Another Function.

Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!