Today I learned that bash has hashmaps (2024)
1–10 of 137 posts
Re: Today I learned that bash has hashmaps (2024)
#2Re: Today I learned that bash has hashmaps (2024)
#3Not only do they exist, but they have some fantastic foot guns! https://mywiki.wooledge.org/BashPitfalls#A.5B.5B_-v_hash.5B....
Re: Today I learned that bash has hashmaps (2024)
#4Re: Today I learned that bash has hashmaps (2024)
#5A couple of weeks ago I learnt that Bash on Mac does not have associative arrays. We worked around the issue by changing the script to run under Zsh, but beware.
$ bash --version
GNU bash, version 5.2.32(1)-release (aarch64-apple-darwin23.4.0)
$ declare -A aaa; aaa[a]=a; aaa[b]=bb; for i in ${!aaa[@]}; do echo "$i --> ${aaa[$i]}"; done
b --> bb
a --> a
Re: Today I learned that bash has hashmaps (2024)
#6A couple of weeks ago I learnt that Bash on Mac does not have associative arrays. We worked around the issue by changing the script to run under Zsh, but beware.
Re: Today I learned that bash has hashmaps (2024)
#7> A: You use the command `declare -A HASHMAP_NAME`
This is why I think Bash is a horrible language
Re: Today I learned that bash has hashmaps (2024)
#8> Q: How do I declare a Hashmap? > A: You use the command `declare -A HASHMAP_NAME` This is why I think Bash is a horrible language
Re: Today I learned that bash has hashmaps (2024)
#9Not only do they exist, but they have some fantastic foot guns! https://mywiki.wooledge.org/BashPitfalls#A.5B.5B_-v_hash.5B....
Otherwise wouldn't be getting the full shell experience.
Re: Today I learned that bash has hashmaps (2024)
#10A couple of weeks ago I learnt that Bash on Mac does not have associative arrays. We worked around the issue by changing the script to run under Zsh, but beware.
Sounds like a bash 3 issue. $ bash --version GNU bash, version 5.2.32(1)-release (aarch64-apple-darwin23.4.0) $ declare -A aaa; aaa[a]=a; aaa[b]=bb; for i in ${!aaa[@]}; do echo "$i --> ${aaa[$i]}"; done b --> bb a --> a