6

I am on MacOS Cagalina 10.15.4. I thought mapfile and readarray are available with Bash 4 and later but got below. May I ask what I am doing wrong?

$ brew install bash
$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-apple-darwin19.4.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

$ mapfile
-bash: mapfile: command not found

$ readarray
-bash: readarray: command not found
mon
  • 18,789
  • 22
  • 112
  • 205
  • If you're using bash try `type -a bash`, since the default `bash` on Mac is `3` you need to locate the path of the new bash and add it to your `PATH` or call the absolute path. – Jetchisel May 06 '20 at 23:30
  • 1
    Use `declare -p BASH_VERSION` to check the current version. – Charles Duffy May 06 '20 at 23:36
  • 4
    `bash --version` tells you what version is first in the PATH. It **does not** tell you which version you're currently running. – Charles Duffy May 06 '20 at 23:37
  • 3
    @Jetchisel, the OP's PATH is perfectly fine already, as we know since `bash --version` shows the new shell. The problem is that their `/etc/passwd` entry (or whatever modern MacOS uses as an equivalent) is pointing to `/bin/bash` or otherwise something *older* than the shell in the first spot in their PATH. `chsh` or a similar tool will thus be the Right Thing. – Charles Duffy May 06 '20 at 23:38
  • Ok, then `getent passwd mon` should show that yes? – Jetchisel May 06 '20 at 23:42
  • I have it on my `FreeBSD` here. – Jetchisel May 06 '20 at 23:43
  • As an alternative to `getent` that I've tested to work on Catalina: `python3 -c 'import pwd, os; print(pwd.getpwuid(os.getuid()).pw_shell)'` – Charles Duffy May 06 '20 at 23:47

0 Answers0