Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
944 views
in Technique[技术] by (71.8m points)

linux - Bash "declare -A" does not work on macOS

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...