Use the following commands to install and use the latest version Bash in macOS.

# Install bash and bash-completion using homebrew (https://brew.sh):
brew install bash
brew install bash-completion

# Add brew-installed bash to allowed shells:
sudo echo "/usr/local/bin/bash" >> /private/etc/shells

# Change the current user's default shell to brew-installed bash:
chsh -s /usr/local/bin/bash