Skip to content
BIASED

The shell and text tools

Block 1 of 6~2 min

Silent failure by default

The previous topic described delivery as a stream of steps from a commit to production. A step becomes cheap when a machine can run it, and almost every step — building, testing, packaging, copying, restarting — is in the end a sequence of commands. The language of those commands is the shell.

The simplest automation is none: an engineer types commands from a wiki. Saving them in a file does not fix silence by itself. A three-line cleanup script without safeguards, run with an empty BUILD_DIR where the build directory is missing:

#!/usr/bin/env bash
cd /nonexistent/build
echo "still running, in ${PWD##*/}"
echo rm -rf "$BUILD_DIR/tmp"

The cd fails and the script continues in the wrong directory. The empty variable turns $BUILD_DIR/tmp into /tmp. Without the echo, the script would try to delete /tmp. Both mistakes are silent by default.

Answers are saved on the server and tied to this browser until you sign in.