Submission timeline
2007–2026One 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 orderThe article is dangerously wrong in its discussion of IFS. What you should do to avoid the problem of mishandling spaces is use proper quoting (for i in "$@"; do ...), not changing IFS; setting IFS to \n\t will still break embedded tabs and newlines. In general, in bash scripts any of use of $ should always be between double quotes unless you have a reason to do otherwise.
Better than set -e is trapping ERR. You can set up a trap that prints out the command that failed, and the line it's on, rather than just dying quietly like set -e does. It's much easier to debug that than trying to work ahead from the last command with output. For bonus points, when you have a bunch of scripts together, put the trap code in its own file and source it in all the other scripts (rather than…
Stylistically, I much prefer #!/bin/bash set -o errexit set -o nounset set -o pipefail It reminds me when I wrote a lot of Perl: #!/usr/bin/perl use strict; use warnings; I also prefer --long --args everywhere possible and a comment on any short flag unless it's incredibly common. I've been writing all my Bash scripts like this for ~15 years and it's definitely the way to go.
The Bash FAQ disagrees: https://mywiki.wooledge.org/BashFAQ/105 The TFA is referenced at the bottom of this FAQ.
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
- 2
- Total points
- 400
- Total comments
- 150
100+ points or 50+ comments
reference only — not used in Hall rules or ranking
reference only — not used in Hall rules or ranking
