25

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?

22

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
$ chsh -s /usr/local/bin/bash
$ sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
$ ln -s /usr/local/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 save 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.

| improve this answer | |
  • that last ln -s was the missing step for me. – javadba Jul 18 '17 at 21:15
  • 1
    this doesn't work for me. /usr/local/bin/bash was not created by brew. Also, what is bash-terminal-app? – glS Feb 2 '18 at 10:10
  • @klanomath Sierra 10.12.6 and brew 1.5.2. The executables are installed in /usr/local/Cellar/... and usually linked in /usr/local/bin. For some reason though, bash seems to be an exception. brew doctor reveals the probable reason as being that bash could not be linked, but if I try brew link bash I get that the symlink could not be created because /usr/local/share/locale/ca/LC_MESSAGES is not writable. I checked and brew was not installed as root, as advised in the home page. – glS Feb 2 '18 at 10:19
  • /usr/local/share/locale/ca/LC_MESSAGES is indeed owned by root so not writable without root access, but I'm not sure whether I can safely just chown it. Is this file even supposed to be owned by root? – glS Feb 2 '18 at 10:21
  • @glS Added addendum... – klanomath Feb 2 '18 at 13:07

You must log in to answer this question.

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