I think it maybe a lack of capitalization getting in the way...
declare -A _sites=( ["fr"]="frederick" ["an"]="annapolis" )
for i in "${!_sites[@]}"; do
printf '%s -> %s\n' "${i}" "${_sites[$i]}"
done
Resources that where helpful in sorting the above out are not limited to the following;
After reading the other posted answer's comments I think you'll want that last listed answer's work-around if stuck with older version of Bash that cannot be updated for reasons.
@Fenn a few more notes...
hash-set() {
HASH_NAME="$1" ; shift
HASH_KEY="$1" ; shift
HASH_VAL="$1" ; shift
eval "export ${HASH_PREFIX}_${HASH_NAME}_KEY_${HASH_KEY}='$HASH_VAL'"
}
... without shift
ing, or eval
, and with required arguments might look like...
hash_set(){
local _name="${1:?${FUNCNAME[0]} not provided a Hash Name}"
local _key="${2:?${FUNCNAME[0]} not provided a Hash Key}"
local _value="${3:?${FUNCNAME[0]} not provided a Value}"
declare -g "${HASH_PREFIX}_${_name}_KEY_${_key}='${_value}'"
}
... hopefully this is a bit more helpful in translating that answer into something that can be up-voted.