Is it possible to actually update bash to version 4.0 in OSX Yosemite?


This article and this thread refer to the same question, but they install a new shell side-by-side with the old one. Is there a way to directly update the old bash shell?

  • 3
    There is no need to do that. In fact, it is always a good idea to keep the original one. Two or more versions of bash can be installed at the same time, and you can set whichever one you like to be the default – lupincho Jun 28 '15 at 12:32
  • Essentially Apple's Software Update would be responsible for changing the version of BASH on the system, like it did with the update to BASH for Shellshock. So unless Apple provides an update then there is no direct way to update to the latest version of GNU BASH that came installed as part of OS X. An indirect way would be to download it yourself, by one means or another, and instal it and then set it as your default shell. Whether or not you choose to remove the shipped version or Apple updated version, that's up to you. – user3439894 Jun 28 '15 at 17:26
up vote 27 down vote accepted

Apple will not update Bash, because the latest version is licensed under GPLv3, which Apple cannot use. They have updated most of their other shells though. ZSH for example is mostly up to date.


After a bit of research, this seems like the primary issue:

When people distribute User Products that include software under GPLv3, section 6 requires that they provide you with information necessary to modify that software. User Products is a term specially defined in the license; examples of User Products include portable music players, digital video recorders, and home security systems.

This would require that otherwise closed-source software, have its GPL'd portions be made modifiable by the public, which would obviously be an issue for Apple.

  • Comments are not for extended discussion; this conversation has been moved to chat. – bmike Nov 19 '17 at 0:15
  • 3
    This explanation does not make sense. Shipping a GPL (v3 or otherwise) binary does not mean that the rest of the OS would need to be released. The rest of the OS does not link to bash. The "Tivoization" clause might explain why bash can't be updated on, say, an Apple TV, but not really on a desktop Mac. Furthermore, "GPL'd portions" already would need to be made modifiable by the public; v3 would not change that. I would believe that the patents clause of GPL v3 would be sufficient to deter Apple from touching GPL v3 code. – jamesdlin Jun 19 at 17:41
  • Why would that be an issue for Apple? Bash is already open source (all versions ≥1.14 are available via GNU @ & the version included with macOS (currently v3.2) is available via Apple @, but it could be modified regardless. – tjt263 Dec 7 at 9:28
  • @tjt263 It's about the differences between GPLv3 and GPLv2, which the version Apple uses, is still licensed under. – William T Froggard Dec 9 at 0:19
  • Right, Bash3.2 is licensed under GPLv2. Bash4.x is licensed under GPLv3. So what? You said: "Apple will not update Bash, because the latest version is licensed under GPLv3, which Apple cannot use." Why can't they? "This would require that otherwise closed-source software, have its GPL'd portions be made modifiable by the public, which would obviously be an issue for Apple." Why is that an issue? They do that already. It's already modifiable by the public. All software is. Especially when it's FOSS and they're giving away the source code on their site to anyone who wants it. – tjt263 Dec 9 at 1:11

Is it possible to actually update bash to version 4.0 in OSX Yosemite? Yes.

  1. Download / Install homebrew by running this command in terminal.

    ruby -e "$(curl -fsSL"
  2. Quit and reopen your terminal. then type

    brew install bash
  3. Change the default shell via the terminal gui with the literal path of your new bash (EDIT: I have yet to find a CLI way that works )

enter image description here

Is it possible to actually update bash to Apple’s provided bash version 4.0 in OSX Yosemite?

EDIT: No. Not in the way the op is asking. E.g upgrade the current install by way of replacing itself. It has been noted in other answers that Apple has not updated bash due to licensing issues. However downloading an updated and separate version of bash and using it as your default shell is the canonical solution, for most interpreters. Take python for example. You do not upgrade 2.7 to 3.5 you download a separate version and change your default.

  • 9
    You can set the default via the CLI with: sudo chpass -s /usr/local/bin/bash. Note: It's best to point to the symlink in /usr/local/bin/ that way Brew can handle upgrades without having to change your environment each time. – sansSpoon Dec 8 '17 at 9:38
  • what are the risks of going with a non-Apple shell? – Mike Palmice Oct 17 at 6:30

As @William said in his answer, Apple does not provide bash 4 due to GPL restrictions. You can install bash 4+ however and also can make it your default shell (including for Terminal and iTerm2) by doing the following.

First install the newer version of bash. There are various ways of doing that, I prefer Homebrew.

  • Install Homebrew as described at
  • Install bash using brew install bash.

Bash is now available and the active shell for the current session. You can find where it is located by running which bash. In my case it is at /usr/local/bin/bash. This new bash can now be used in scripts by using a Shebang with the new bash path at the start of scripts. You can also use it for specific profiles in Terminal/iTerm2 using the steps described in @user136952's answer.

...your script...

I'm assuming this what you mean by "side by side" in your question. To make bash the default you need to do two more steps.

First, add that bash path to your /etc/shells file. As described in /etc/shells, this file has the list of valid login shells. Before the new bash can be the default it has to valid. After adding the new bash path my /etc/shells looks like the following:

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.


Finally we can use chsh to make it the default shell. You can read more about this in Change the Shell in Mac OS X Terminal, but the actual command is very straightforward.

sudo chsh -s /usr/local/bin/bash

Now the new bash is our default shell. If you open Terminal or iTerm2 and run bash --version you should see the new version. Note the "License GPLv3+" which is why Apple doesn't bundle it with macOS.

$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.6.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
  • He mentioned that he specifically doesn't want the install-side-by-side option. – William T Froggard Oct 22 '17 at 11:21
  • 2
    Based on article/thread he linked to I think he really meant "not default" by saying not side-by-side. My answer makes 4 the default so 3 is no longer seen. The fact that the old bash happens to still be taking up some disk space doesn't seem like a big issue to me. – studgeek Nov 18 '17 at 0:44
  • 1
    +1 by me. Yes, OP doesn’t want this, but the question belongs to the community and if this helps other people, awesome. It might not get a check as the answer the OP selects, but that doesn’t make it a bad answer. – bmike Nov 19 '17 at 0:17
  • @studgeek, are there any long-term side-effects to making bash4 the default shell for the root user on Mac OS X? I ran the chsh command but am going to attempt to remember that if things go haywire, I need to change it back. However, it would help put my mind at ease knowing the answer to this question. Thank you! – harperville Jan 7 at 17:34
  • 3
    On High Sierra, sudo chpass -s /usr/local/bin/bash changes my shell for root/sudo only. To change for my regular login, I must run the command without sudo. This might be an Active Directory thing; I’m not sure. – Bradd Szonye May 9 at 21:29

You can install another version of Bash without homebrew

  • Go to GNU Bash
  • Download the version you want (here)
  • And follow the steps here:

    Download and install bash version you want Replace X.X (in bash-X.X) with the version you want e.g 4.4

    curl -O
    tar xzf bash-X.X.tar.gz
    cd bash-X.X
    ./configure --prefix=/usr/local && make && sudo make install

    Add the new shell to the list of legit shells

    sudo bash -c "echo /usr/local/bin/bash >> /private/etc/shells"

    Change the shell for the user

    chsh -s /usr/local/bin/bash

    Check for Bash 4 and /usr/local/bin/bash...

    echo $BASH && echo $BASH_VERSION

    You might want to add an alias if you want the bash command to use it. Place in your ~/.bash_profile

    alias bash="/usr/local/bin/bash"

The side-by-side install with an update to your shell (via chsh or the GUI) will fail for scripts. Scripts often use env bash, which reverts to the OS X bash version. So, what you want may not be the complete update of bash, but a side-by-side install that always returns the newer version of bash (i.e. even when env is invoked).

So, to handle this:

1) install bash via Homebrew, as the other commenters have posted

2) set your login shell to this new version (via the GUI or chsh command as others have posted)

3) set /usr/local/bin (or the path to the new bash version) ahead of /bin on your $PATH variable, by adding this to your ~/.bash_profile: export PATH=/usr/local/bin:$PATH

  • This will break scripts that expect bash version 3 - ie Apple supplied scripts - you need to use sde by side – Mark Jun 12 at 11:30
  • A fair point. Been running like this for some time now and no issues. Maybe Apple provides the full path in its scripts or it just hasn't hit a snag. For apple system level scripts, i.e. not from a shell, it never calls the .bash_profile anyway, so it would only impact something you run directly in a terminal anyway. – cwingrav Jun 13 at 20:08
  • @Mark I can't think of an instance where v ≥4.x would break a script written for v ≤3.x. Can you? – tjt263 Dec 7 at 9:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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