HN Hall of Fame Weekly email

Bash Pitfalls

mywiki.wooledge.org Reference Documentation & references Software engineering Class of 2020-09 Hall of Fame
Screenshot of mywiki.wooledge.org captured 2026-07-20
Page preview · captured 2026-07-20

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

submissions
11
submitters
11
observed span
2009–2026
peak thread · 111 comments
288 pts
latest 20+ return · 2022-02-15
106 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

I consider shellcheck absolutely essential if you're writing even a single line of Bash. I also start all my scripts with this "unofficial bash strict mode" and DIR= shortcut: #!/usr/bin/env bash ### Bash Environment Setup # http://redsymbol.net/articles/unofficial-bash-strict-mode/ # https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html # set -o xtrace set -o errexit set -o errtrace set -o nounset set -o pipefail IFS=$'\n' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" I have more…

If your bash script is not trivial, and target machines have python, it's probably better to use sh: https://amoffat.github.io/sh/

monort·114-point thread·

It's the problem of nested DSLs (sed, tr, globing, bash's own control commands etc): you need to quote (escape) each DSL's meta-characters like crazy. It's a scary, horrific nightmare. Sure, you can learn all the intricacies, but what a waste of your cognition! There must be a way to do it with clean abstractions (assuming the unrealistic liberty to redesign all unix commands). But... I have a suspicion that the horror is intrinsic to the problem, and bash strikes a…

10ren·60-point thread·

This sounds more like a case of “know what the things in your pipeline do, if it’s odd/abnormal” than “avoid -o pipefail”.

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
589

reference only — not used in Hall rules or ranking

Total comments
207

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2009-10-08Common Bash Pitfallsdunk0106025
2014-10-10Bash pitfallsgeneral_failure20
2015-08-16Bash PitfallsFirst breakoutmonort11438
2019-01-06Bash Pitfallsaaaaaaaaaab20
2020-09-07BashPitfallspraveenscience20
2020-09-07Bash PitfallsHall induction · Best threadaaron-santos288111
2022-02-15Bash PitfallsLatest 20+ point returnpujjad10632
2024-04-04Avoid "set -o pipefail" in bashrom1v31
2024-07-04BashPitfalls – Greg's Wikiwhereistimbo50
2026-01-30Bash PitfallsTikrong20
2026-05-11Bash Pitfalls - Greg's Wikidr_girlfriend50