HN Hall of Fame Weekly email

Common shell script mistakes (2008)

www.pixelbeat.org Books & learning Tutorials & guides Software engineering Candidate
Screenshot of www.pixelbeat.org captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 4 calendar years, with breakout response in 3 of them.

submissions
5
submitters
5
observed span
2010–2021
peak thread · 79 comments
166 pts
latest 20+ return · 2021-12-07
81 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

Shout out to Shellcheck (http://www.shellcheck.net/), a linter for shell scripts

The single biggest shell script mistake is not handling whitespace in file names correctly, and it's almost impossible to do correctly if you have weird file names: embedded newlines, leading and trailing spaces, embedded tabs. Embedded quotes can be tricky too, especially if you're writing a script that generates a script. That bit, writing a script that generates a script, happens surprisingly often in bash. It's cheaper to pipe a stream to sed that converts it into a shell command…

barrkel·117-point thread·

Advice at a higher level: don’t try too hard to handle error cases in your scripts. The best shell scripts are a list of imperative instructions to get something done. If an error occurs, bail as early as possible and with a useful message. Don’t try any harder than that. For example: if ! complex_function then handle_error fi …doesn’t work as you’d expect because the “if” context changes the rules of set -e in complex_function. It’s much better to have…

Note the #status anchor is best removed from the url

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
3

100+ points or 50+ comments

Total points
388

reference only — not used in Hall rules or ranking

Total comments
168

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2010-01-17Common shell script mistakesmiles200
2013-11-17Shell script mistakesFirst breakoutreinhardt11734
2016-06-03Common shell script mistakes (2008)Best threadpmoriarty16679
2016-09-19Common shell script mistakesot42
2021-12-07Common shell script mistakes (2008)Latest 20+ point returngautamsomani8153