/bin/bash shell (macOS) throwing `-bash: declare: -A: invalid option` error message at shell start

I briefly changed my default shell on macOS Catalina (10.15.1) to Fish, following the steps in Fish's documentation.

First, I executed > echo /usr/local/bin/fish | sudo tee -a /etc/shells followed by > chsh -s /usr/local/bin/fish. After, I realized I only needed to use one of these commands, not both, but oh well. What's done is done.

Later, I decided to switch back to bash, so I ran the commands in reverse (according to Fish's instructions for reverting) First, > echo /bin/bash | sudo tee -a /etc/shells followed by > chsh -s /bin/bash

When I reloaded the shell using Bash, I received the following error.

-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: complete: -D: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit 

This error did not appear before changing the shell to Fish and then back to Bash, and I didn't edit any .bashrc or .bash_profile files before changing the shell back to Bash. Can someone help me resolve this?

1

1 Answer

The /bin/bash that ships with macOS Catalina is really old (version 3.2.57) and does not support declare -A. Presumably you had been using the Homebrew version installed as /usr/local/bin/bash which does support declare -A. So assuming you have a /usr/local/bin/bash simply ensure that is present in /etc/shells then run chpass -s /usr/local/bin/bash.

P.S., You can view your current user profile, which includes your default shell, by simply typing chpass with no options.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like