MacOS – /bin/bash not executing any commands

bashcommand linemacos

I set /bin/bash as my default shell like this:

chsh -s /bin/bash

But it doesn't work when I open a new terminal tab. If you type any command, e.g. ls, no output is printed.

Likewise if I simply run /bin/bash from a working shell it behaves the same way.

My current shell is /bin/sh.

I'm trying to change my shell to bash because the current shell (/bin/sh) doesn't execute neither ~/.bashrc nor ~/.bash_profile for some reason, although it appears to be bash too:

$ /bin/sh --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc

I used to use zsh together with oh-my-zsh but it was unacceptably slow, so I'm switching back.

I used bash before that. Both of those files I mentioned were executing at that time (I didn't change the configuration).

Best Answer

I have found the culprit:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  source $(brew --prefix)/etc/bash_completion
fi

These lines in my ~/.bashrc were causing bash to hang up on startup and it wasn't executing any commands as a result. Commenting them out solved the issue.

Apparently, there is some error in that script (it's part of Homebrew's bash-completion package).