3 ms·
> Bash should be considered an esoteric programming language. Shell Programming Considered Harmful. I disagree. Bash is fine. Nothing esoteric about it. > It'
by rascul 5y ago
> Bash should be considered an esoteric programming language. Shell Programming Considered Harmful.
I disagree. Bash is fine. Nothing esoteric about it.
> It's hard to program, and easy to make mistakes in. It should be left as a tool of last resort.
It's easy to program, but it has a learning curve. Use shellcheck. It's OK to go first to bash if you need a shell script. Other languages make pretty crappy shell scripts.
- pizza234 5y agoI copy/paste from a previous post. "Exoteric" is a stretch (in particular, because there are no alternative glue languages, if we exclude all the shell variants), but cryptic, unintuitive and error-prone fits well. Arrays: - `${#myvar[@]}`: unreadable - `mapfile myvar < <(grep pattern file)`: "mapfile" is not exactly a clear term (there's the synonym "readarray", but "mapfile" is the reference; worse, you may find both used inconsistently); the command as I wrote it also has two problems Strings: - `${myvar##.*}`: unreadable - `echo $(IFS=,; echo "${myvar[*]}")`: unreadable; most also don't know the difference between `[@]` and `[*]`; this doesn't also work for two-char join operations - `[[ $myvar =~ $(echo '\bpattern\b') ]]`: unreadable, and most don't know why command substitution is needed Redirections: - `3>&2 2>&1 1>&3`: most don't know what this means
- marklgr 5y agoYes, it can be cryptic and not beginner-friendly, but it's powerful and once you know it, you know it; it will be useful for years if not decades, as opposed to some tools or frameworks du jour that are sometimes as cryptic. The main issue is that many people try (by necessity or not) to cobble scripts together without really learning the language and its idioms. It's not that hard to really learn it though, it's basically one man page then the mandatory [wooledge wiki][1]. [1]: http://mywiki.wooledge.org/BashGuide http://mywiki.wooledge.org/BashGuide
- rascul 5y agoI don't understand, none of that is unreadable or weird to me. Are you sure the issue is not a lack of familiarity with the language? The language can appear deceptively simple in the beginning.