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.
echo $BASH_VERSIONright before doing theshopt. – user1934428 Apr 12 '23 at 08:25bashexecutable in your PATH, but not of thebashprocess 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. – user1934428 Apr 13 '23 at 06:03