> 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
Today I learned that bash has hashmaps (2024)
11–20 of 137 posts
Re: Today I learned that bash has hashmaps (2024)
#12A 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.
https://web.archive.org/web/20240810094701/https://meta.ath0...>
Re: Today I learned that bash has hashmaps (2024)
#13https://www.gnu.org/software/bash/manual/bash.html#Arrays>
Re: Today I learned that bash has hashmaps (2024)
#14Re: Today I learned that bash has hashmaps (2024)
#15Having to implement hash-tables, while still keeping the appearances of everything being a string is the anti-pattern known as "string programming" (i.e. when application develops a convention about storing type / structure information inside unstructured data, often strings).
I would love for there to be a different system shell with a small number of built-in types that include some type for constructing complex types. There are many languages that have that kind of type system: Erlang, for example. But, extending Unix Shell in this way is not going to accomplish this.
Re: Today I learned that bash has hashmaps (2024)
#16Re: Today I learned that bash has hashmaps (2024)
#17Now to add hashtables to that.
Re: Today I learned that bash has hashmaps (2024)
#18A lot of the sins of shell are due to it's primary focus as an interactive language. Many of those features that make it so nice interactively really hurt it as a scripting language.