Today I learned that bash has hashmaps (2024)
22 points by stefankuehnel 2 days ago | 4 comments
  • aunderscored 2 days ago |
    Not only do they exist, but they have some fantastic foot guns! https://mywiki.wooledge.org/BashPitfalls#A.5B.5B_-v_hash.5B....
    • stefankuehnel 2 days ago |
      Interesting, definitely need to keep that in mind.
  • oniony 2 days ago |
    A 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.
    • ptdorf a day ago |
      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