Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, Bite Size Bash!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript". get the zine!
read the transcript!

by default, bash will continue after errors

bash, represented by a box with a smiley face: oh, was that an error? who cares, let’s keep running!!!

programmer, represented by a nonplussed stick figure with short curly hair: uh that is NOT what I wanted

set -e stops the script on errors

set -e
unzip fle.zip

(typo! script stops here!)

programmer, smiling: this makes your scripts WAY more predictable

by default, unset variables don’t error

rm -r "$HOME/$SOMEPTH"

bash, happily: $SOMEPTH doesn’t exist? no problem, i’ll just use an empty string!

programmer: OH NOOOO that means rm -rf $HOME

set -u stops the script on unset variables

set-u
rm -r "$HOME/$SOMEPTH"

bash, concerned: I’ve never heard of $SOMEPTH! STOP EVERYTHING!!!

by default, a command failing doesn’t fail the whole pipeline

curl yxqzq.ca | grep 'panda'

bash, pleased with itself: curl failed but grep succeeded so it’s fine! success!

set -o pipefail makes the pipe fail if any command fails

you can combine set -e, set -u, and set -o pipefail into one command I put at the top of all my scripts:

set -euo pipefail