Hacker News new | ask | show | jobs
by qbasic_forever 1565 days ago
We really need a 'Bash: The Good Parts' book like Doug Crockford did for Javascript. IMHO bash and the shell are in a state that Javascript was ~2005--an old language/tool full of complexities but that can be sharpened and honed down to something beautiful.

IMHO writing procedural style code with lots of if, loops, etc. in the shell can quickly turn into an anti-pattern. Try to stick to simple functions that are chained together in pipelines. The only loop is typically one that processes arguments and that's it.

3 comments

> We really need a 'Bash: The Good Parts' book like Doug Crockford did for Javascript.

Bash is incredibly less complex than Javascript and there is such a resource: the "Bash guide" [1] and "Bash pitfalls" [2] are both excellent resources that teach you how to use Bash properly.

[1] http://mywiki.wooledge.org/BashGuide

[2] http://mywiki.wooledge.org/BashPitfalls

I have a coworker who uses make for tasks that do not fit comfortably in a few lines of shell script, and it can make for very elegant and readable solutions. Without giving in to the procedural constructs that are so awkward in shell scripting languages.
That opened my mind… 30 years after I started using make. D’oh!
i do that too...folks seem surprised, but it's handy
Bash really just should die already. I really don’t see it being more available than python is, and the fact that basically every 3+ line bash script is logically faulty should be enough of a reason. Add that they are basically unreadable after writing.
> I really don’t see it being more available than python is

Oh, but which version, 2 or 3?

Bash availability may not be guaranteed, but a POSIX shell of some variety is.