Associative array error on macOS for bash: : declare: -A: invalid option

Dipesh Majumdar
1 min readMay 17, 2023

--

Change shebang* from

#!/bin/bash

to

#!/usr/local/bin/bash

This is because i saw my /bin/bash was old —

/bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.

and the /usr/local/bin/bash is updated one —

/usr/local/bin/bash --version
GNU bash, version 5.2.12(1)-release (x86_64-apple-darwin21.6.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

*The shebang, also known as a hashbang, is the initial line in a script that specifies the interpreter to be used to execute the script. It starts with a shebang character sequence, consisting of a hash symbol (#) followed by an exclamation mark (!), hence the name “shebang”.

The shebang line is typically placed at the beginning of a script file and is used by the operating system to determine which interpreter should execute the script. For example, the shebang line #!/bin/bash indicates that the script should be executed using the Bash interpreter.

--

--