How to upgrade bash with brew (permission error)? I work with Yosemite (10.10.3) and would like to upgrade bash (to version 4.x) and found this post. After brew update, I did brew install bash, but obtained:

==&gt; Downloading https://homebrew.bintray.com/bottles/bash-4.3.33.yosemite.bottle.tar.gz
######################################################################## 100.0%
==&gt; Pouring bash-4.3.33.yosemite.bottle.tar.gz
==&gt; Caveats
In order to use this build of bash as your login shell,
it must be added to /etc/shells.
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied - /usr/local/share/locale/af
Error: Permission denied - /usr/local/share/locale/af


How can I fix this? I cded into /usr/local/share/locale but the directory af doesn't exist. Why does brew try to access this?

Update

I forgot to say, if I use sudo brew install bash, I receive:

Error: Cowardly refusing to `sudo brew install`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
You must be sure that the group of /usr/local and all inside it is admin (I'm supposing your username belongs to admin group too). If this isn't the case, fix it with:

sudo chown -R $USER:admin /usr/local


You will probably have to do the same on /Library/Caches/Homebrew:

sudo chown -R $USER:admin /Library/Caches/Homebrew