The conventional meaning of the SHELL
environment variable is the user's favorite interactive shell. There is no obligation that it has any particular syntax (it doesn't have to be Bourne-like), that it supports any particular command line syntax (such as -c
), or that it has anything to do with the login shell (applications that use SHELL
typically default to the login shell if SHELL
is unsed). It's mostly used by terminal emulators as the program to run by default.
If you log in in text mode (on a text console or over SSH), what you get is the login shell listed in the user database (e.g. /etc/passwd
). When you open a terminal in a GUI environment, you get the shell specified by the SHELL
environment variable if the variable is set. If you want the same shell for text mode logins, either change your login shell with chsh
, or make your login shell switch to your favorite shell with exec
.
Occasionally you might encounter a program that uses $SHELL -c
instead of sh -c
to execute code in sh syntax. But that's pretty rare. It's technically allowed by POSIX, but it would violate historical usage. In practice, setting SHELL
is safe. I've had my login shell set to /bin/sh
and SHELL
set to /path/to/zsh
on most machines for about two decades.
/usr/local/bin/bash
in/etc/passwd
? – John1024 Aug 10 '17 at 22:25/usr/local/bin/bash
in your/etc/shells
? If not run this:sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
. Also just for solidarity make sure you have followed the steps in this guide for your upgrade: http://clubmate.fi/upgrade-to-bash-4-in-mac-os-x/ – jesse_b Aug 10 '17 at 22:26/etc/shells
? That file is only used bychsh
, unless macOS does something unusual. – Gilles 'SO- stop being evil' Aug 10 '17 at 23:11/usr/local/bin
compared to/usr/bin
in yourPATH
? – thrig Aug 10 '17 at 23:27chsh
and a few other system services that are relatively uncommon these days. The point is, it's only used to check the user's current login shell. It has nothing to do with theSHELL
environment variable. – Gilles 'SO- stop being evil' Aug 10 '17 at 23:45SHELL
variable is set by the/etc/passwd
file, however in mac it is not. So in mac the correct way to set your default shell is with thechsh
command we can't stop talking about anyway. – jesse_b Aug 10 '17 at 23:52SHELL=/usr/local/bin/bash
You are setting a shell variable. In order to make it an environmental variable you would need to do:export SHELL=/usr/local/bin/bash
– jesse_b Aug 11 '17 at 00:44/etc/shells
when I did the upgrade. I think I referenced that same page you linked ;) – ivan Aug 11 '17 at 16:53/etc/passwd
corresponding to my user, I'm guessing because I'm on macOS. From the other comments it sounds like that also relates to the use of/etc/shells
when doing this on mac – ivan Aug 11 '17 at 16:57export
in my original post. I'll update... – ivan Aug 11 '17 at 16:59