Top all-time · #3660
David Pashley
Personal blog · davidpashley.comprogrammingsecurity
David Pashley's personal blog at davidpashley.com covers programming and security. Since 2010, 20 different Hacker News readers have linked it 22 times, most often “Writing Robust Bash Shell Scripts”. The last post was in 2016, but the archive is still widely read.
Too few sampled comments (12) to say how often HN recommends it.?
Why HN links it
HN readers link David Pashley's articles on writing robust shell scripts, covering set -e, set -u and safe bash practices, along with a post on disabling DNS prefetching. Commenters cite them in bash discussions.
Summarised by Claude from a sample of 12 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Most-linked posts?
- Writing Robust Bash Shell Scripts8 people · 8 mentions · first linked 2013-08-14
- Writing Robust Bash Shell Scripts5 people · 7 mentions · first linked 2018-12-27
- Writing Robust Bash Shell Scripts4 people · 4 mentions · first linked 2010-04-17
- /blog/computing/livejournal-mozilla-bug.html2 people · 2 mentions · first linked 2010-01-11
What Hacker News says?
See also: * safe ways to do things in bash: https://github.com/anordal/shellharden/blob/master/how_to_do... * better scripting: https://robertmuth.blogspot.in/2012/08/better-bash-scripting... * robust scripting: https://www.davidpashley.com/articles/writing-robust-shell-s...
Comment linking /articles/writing-robust-shell-scripts/
on “Shell script best practices, from a decade of scripting things”Submitted Writing Robust Bash Shell Scripts as a story · 57 points
HN discussionI learnt the same trick some years ago, from an article called Shell Scripts Matter : https://dev.to/thiht/shell-scripts-matter So I took some of the advice and tips offered in there, and wrote a template file to be used as a baseline when writing scripts for any project that might need one: https://github.com/j1elo/shell-snippets/blob/master/template... Other resources that I link in the readme of that repo, becaus…
Comment linking /articles/writing-robust-shell-scripts/
on “Help Message for Shell Scripts”Submitted Writing Robust Bash Shell Scripts as a story · 51 points
HN discussionThere are problems with the manipulation of binary data in bash, as discussed here: https://unix.stackexchange.com/questions/278639/how-can-i-wo... In particular, the value 0 can't be stored in a bash variable, which almost completely rules out the possibility of byte-by-byte processing of general binary data. It's probably possible with absurd hacks. Quite apart from that, error handling in bash is an awkward chore…
Comment linking /articles/writing-robust-shell-scripts/
on “lsix: ls for images”Submitted Bad Password Policies as a story · 29 points
HN discussionSee also: Why doesn't set -e (or set -o errexit, or trap ERR) do what I expected? https://mywiki.wooledge.org/BashFAQ/105 What are the advantages and disadvantages of using set -u (or set -o nounset)? https://mywiki.wooledge.org/BashFAQ/112 Safe ways to do things in bash https://github.com/anordal/shellharden/blob/master/how_to_do... Better Bash Scripting in 15 Minutes https://robertmuth.blogspot.com/2012/08/better-…
Comment linking /articles/writing-robust-shell-scripts/
on “Bash Debugging”Submitted Writing robust shell scripts as a story · 5 points
HN discussionHuh, no mention of "set -e -u"? Do yourself a favor and follow this, too: http://www.davidpashley.com/articles/writing-robust-shell-sc...
Comment linking /articles/writing-robust-shell-scripts/
on “What I learned from others' shell scripts”Submitted Writing Robust Bash Shell Scripts as a story · 4 points
HN discussionthe livejournal change: http://www.davidpashley.com/blog/computing/livejournal-mozil...
Comment linking /blog/computing/livejournal-mozilla-bug.html
on “Saved 10 billion DNS queries per month by disabling DNS Prefetching”Submitted Writing Robust Bash Shell Scripts as a story · 4 points
HN discussionSee also: * https://www.shellcheck.net/ — linting tool to avoid common mistakes and improve your script * Bash Practices: https://mywiki.wooledge.org/BashGuide/Practices * Bash FAQ: https://mywiki.wooledge.org/BashFAQ * safe ways to do things in bash: https://github.com/anordal/shellharden/blob/master/how_to_do... * better scripting: https://robertmuth.blogspot.in/2012/08/better-bash-scripting... * robust scripting:…
Comment linking /articles/writing-robust-shell-scripts/
on “Bash Pitfalls”Submitted Writing Robust Bash Shell Scripts as a story · 2 points
HN discussionTo expound on this: "set -e" is short for "set -o errexit", that is, abort the script if a command returns with a non-zero exit code. "set -u" is short for "set -o nounset", that is, abort the script if a variable name is dereferenced when the variable hasn't been set. I also strongly suggest reading http://www.davidpashley.com/articles/writing-robust-shell-sc... for more things that you should be aware of when writ…
Comment linking /articles/writing-robust-shell-scripts/
on “Diaspora-common: does 'rm -rf /' on purge”Submitted Writing Robust Bash Shell Scripts as a story · 2 points
HN discussionYou could say the same for scripts, languages, etc when not using safety precautions. I would look at the link from erikb's answer: http://www.davidpashley.com/articles/writing-robust-shell-sc...
Comment linking /articles/writing-robust-shell-scripts/
on “Unix filesystems: How mv can be dangerous”Submitted Writing Robust Bash Shell Scripts as a story · 2 points
HN discussionHere's a good article about how it should be done. It does not just say "use move", but it also explains how to backup the old state, how to use traps to remove your workaround code etc. http://www.davidpashley.com/articles/writing-robust-shell-sc...
Comment linking /articles/writing-robust-shell-scripts/
on “Unix filesystems: How mv can be dangerous”Submitted Writing Robust Bash Shell Scripts as a story · 1 points
HN discussionLooking for more about this, I found a pretty good post: http://www.davidpashley.com/articles/writing-robust-shell-sc...
Comment linking /articles/writing-robust-shell-scripts.html
on “Simple git workflow with hack and ship”On further inspection, I don't trust your implementation at all. You're blacklisting CSS rules and attributes rather than whitelisting them. This means you wouldn't catch attacks like this one, for example: http://www.davidpashley.com/blog/computing/livejournal-mozil... I also don't think you're the right thing when you DO find something that's not on the whitelist - you should be escaping it rather than stripping i…
Comment linking /blog/computing/livejournal-mozilla-bug.html
on “XSS war: a powerful Java HTML sanitizer”