Bash “declare -A” does not work on macOS

2019-04-25 07:04发布

My guess is that Bash is not updated on macOS. When googling update Bash macOS, I keep getting the bug fix patch. Anyway, I need to use associative arrays in macOS Bash where the command:

declare -A

yields the error:

-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]

I have Yosemite.

1条回答
混吃等死
2楼-- · 2019-04-25 07:29

declare -A (associative arrays) are a bash 4+ feature.

The OS X bash is likely 3.X.

I don't know that OS X has an official update for bash 4+.

brew/etc. might though.

查看更多
登录 后发表回答