macOS Catalina doesn't support anymore bash and came with zsh, I didn't test this guideline in the macOS Catalina or Big Sur.
macOS comes with a really old bash version. Check the version from the environment variable..
$ echo $BASH_VERSION
We can install a newer version of bash via Homebrew package manager, get Homebrew from here https://brew.sh.