1

On a new mac, trying to switch to bash for a minute:

alex.mills@alex uta-phd %
alex.mills@alex uta-phd % echo $SHELL
/bin/zsh
alex.mills@alex uta-phd %
alex.mills@alex uta-phd % exec bash

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. %na%m %1~ %# %na%m %1~ %# echo $SHELL /bin/zsh %n@%m %1~ %#

echo "$SHELL" keeps saying I am using /bin/zsh

What to do?

Kusalananda
  • 333,661
  • 2
    Related https://unix.stackexchange.com/a/558387/414186 . You can use su - $USER -s /bin/bash to login with bash and load all environment correctly. (you actually are using bash when run exec bash ) – Edgar Magallon Nov 12 '22 at 05:11
  • 3
    echo "$SHELL" doesn't tell you anything useful for purposes of this question -- SHELL isn't intended to represent the current shell; instead, it's documented to represent it's the user's preferred shell. declare -p BASH_VERSION if you want to conclusively know if you're in bash; ignore SHELL, which is completely irrelevant. – Charles Duffy Nov 13 '22 at 15:16

3 Answers3

17

You are running bash. That's why the prompt looks weird. Bash and zsh both use the PS1 variable as the main setting for the prompt, but they have different escape sequences (backslash-character in bash, percent-character in zsh, and the second characters have different meanings).

Normally the PS1 variable should be set by the shell's initialization file (.bashrc or .zshrc) and not exported to the environment (since it only makes sense inside one given program), but many systems (including major Linux distributions) are poorly configured and export PS1. MacOS correctly does not export PS1 out of the box as far as I can tell, but it seems that your own files do (or maybe a different version of macOS from the one I checked), and for some reason the system bashrc on macOS specifically does not change PS1 if it's already set.

The SHELL environment variable does not indicate what shell you are running. It indicates what shell you want to run. It tells programs that want to start a shell which shell to run. Just running another shell manually does not change $SHELL.

If you see a shell prompt and you aren't sure what shell is running, you can check with ps. In all Bourne-style shells (sh, ash, bash, ksh, zsh, …), $$ stands for the shell's process id, thus ps $$ tells you what program the current shell is. In fish you'd get an error that makes it obvious you're running fish because $$ is not valid there.

1

Why are you trying exec bash? To launch a bash shell, just run bash. For a shell that acts as a login shell, use bash -l. To permanently change your shell to bash, use chsh.

DopeGhoti
  • 76,081
0

Did you changed the shell afterwords? If not then invoke chsh -s $(which bash) and echo $SHELL.