The new globstar option requires bash 4. So.. Which bash are we on?

 $bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Let us try out globstar :

13:39:28/forecast-fresh $shopt -s globstar
-bash: shopt: globstar: invalid shell option name
13:39:32/forecast-fresh $

Is there any way to get support for this on macOS?

  • You are not testing the bash version of your shell in a reliable way. Do a echo $BASH_VERSION right before doing the shopt. Apr 12, 2023 at 8:25
  • @user1934428 That's interesting it shows a very different (lower) version Apr 12, 2023 at 17:32
  • That's why I said that your way to determine the version does not make sense. It shows the version of the first bash executable in your PATH, but not of the bash process you are running now. I would as a first step collect all bash executables you have on your disk and check their versions. Then use for your script the one with a sufficiently high version. Apr 13, 2023 at 6:03

2 Answers 2


Entering shopt will get you a list with all bash options which doesn't include globstar for Apple's bash. Probably bash is compiled without support for this option.

To get a bash executable with globstar install brew and brew's bash:

brew install bash
sudo bash -c "echo $(brew --prefix)/bin/bash >> /etc/shells"
chsh -s $(brew --prefix)/bin/bash
ln -s $(brew --prefix)/bin/bash /usr/local/bin/bash-terminal-app

Then change the default shell opened in Terminal to /usr/local/bin/bash-terminal-app and to suppress the ‘Do you want to close this tab?’ prompt when closing windows and tabs, add -bash to the list of exclusions.

The new option list is then:

$ shopt
autocd          off
cdable_vars     off
cdspell         off
checkhash       off
checkjobs       off
checkwinsize    on
cmdhist         on
compat31        off
compat32        off
compat40        off
compat41        off
compat42        off
compat43        off
complete_fullquote  on
direxpand       off
dirspell        off
dotglob         off
execfail        off
expand_aliases  on
extdebug        off
extglob         off
extquote        on
failglob        off
force_fignore   on
globasciiranges off
globstar        off
gnu_errfmt      off
histappend      off
histreedit      off
histverify      off
hostcomplete    on
huponexit       off
inherit_errexit off
interactive_comments    on
lastpipe        off
lithist         off
login_shell     on
mailwarn        off
no_empty_cmd_completion off
nocaseglob      off
nocasematch     off
nullglob        off
progcomp        on
promptvars      on
restricted_shell    off
shift_verbose   off
sourcepath      on
xpg_echo        off

Under certain circumstances /usr/local/share/ and its subfolders are owned by root (e.g after installing smartmontools, nmap, node etc. with their custom installers) and some of the steps fail. In my opinion it’s safe to chown -R the folders to the admin user who installed brew/bash. In my almost vanilla install of macOS and brew, /usr/local/share and /usr/local/share/locale are owned by this admin user.

  • 1
    I've edited to make it work on both Intel and ARM. Don't understand the need for bash-terminal-app though, what is the benefit of this compared to just point Terminal to $(brew --prefix)/bin/bash?
    – nohillside
    Apr 12, 2023 at 6:17

It seems like install dir for the new version of brew's bash 5 has moved so I needed to do:

sudo ln -s /opt/homebrew/bin/bash /usr/local/bin/bash-terminal-app
exec bash

I also had to add it to my ~/.bash_profile

export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
  • As written this doesn't answer the question asked. Should this maybe have been an edit to the other answer to point out the differences between Intel and ARM installations of Homebrew?
    – nohillside
    Apr 12, 2023 at 6:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .