I have an associative array of dotfile names to ids that looks exactly like this:
declare -A ids=(
[".steve"]="1 4 5 6 10"
[".john"]="3 4 5 1 11"
...
)
When I run this code I get:
./declare_ids.sh: line 23: .steve: operand expected (error token is ".steve")
This error seems really, really vague. I don't understand what is going on. I'm pretty new to bash and have just been learning about associative arrays in bash v4. Could anyone help?
EDIT:
The shebang line in this script is #!/bin/bash
. I am running this inside of a zsh
terminal on OS X, and I installed bash via brew install bash
.
bash --version
says:
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin15.6.0) │
Copyright (C) 2016 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.
This is also the case when I put bash --version
immediately before the declare -A
line.
and which bash
returns /usr/local/bin/bash
. The script is invoked inside the terminal simply by typing ./declare_ids.sh
.
EDIT AGAIN:
As it has already been said echoing $BASH_VERSION
is different than bash --version
. $BASH_VERSION
is 3.2.57(1)-release.
Is there a way to make /bin/bash upgraded? I use this script on a ubuntu circleCI box as well, so anything hardcoded to what brew
does would be bad.