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 https://support.apple.com/kb/HT208050.

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
    You only need to (/should) use the echo /path/to/shell | sudo tee -a /etc/shells command if the shell you want is not already listed in /etc/shells. /usr/local/bin/fish almost certainly wasn't, but /bin/bash was. You should check to see what's already there before adding others (or the same ones again). – Gordon Davisson May 31 '20 at 22:06

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.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.