Live data from Hacker News

Today I learned that bash has hashmaps (2024)

xeiaso.net

11–20 of 137 posts

Re: Today I learned that bash has hashmaps (2024)

#12
post #4

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.

Many programs on macOS are stuck in the ancient past, due to Apple:

https://web.archive.org/web/20240810094701/https://meta.ath0...>

Re: Today I learned that bash has hashmaps (2024)

#14
post #4

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.

You should be getting bash from homebrew anyways.

Just use the included zsh.

Re: Today I learned that bash has hashmaps (2024)

#15
To me, this is a development in the wrong direction. Shell is great precisely because it's so minimal. Everything is string rule is one that calms all of your type-induced fears.

Having 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)

#18
I love shell, I think it's killer feature are pipes and whoever figured out how to design so you can pipe in and out of control structures(Doug Mcilroy?) is a goddamn genius. however, after writing one to many overly clever shell scripts, I have a very clearly delineated point in which the script has become too complex and it is time to rewrite in a language better suited for the task. and that point is when I need associative arrays.

A 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.

Post reply on HN