Change the shell that functions use In my current terminal setup, I make use of zsh; it's my default shell. I also have an up-to-date version of Bash for other reasons installed from Homebrew.

However, there is also the Bash provided by Apple which is at version 3.2.57.

I've my own functions setup and a particular one requires a feature starting from Bash 4.0. Even though my default shell is zsh and I aliased sh(Apple's bash) command to bash(the bash from Homebrew) command, the function I've defined still defaults to using sh and hence, my function doesn't/can't function. I've also changed the shebang at the head of the file defining my custom function but no help.

How can I make that function I've defined default to using the bash installed from Homebrew?
You can turn the function into a shell script and define the shell to be used in the first line

#!/usr/local/bin/bash

# the content of your function goes here


Then make the shell script executable and put it somewhere into your PATH.