A trace that leaves a question open#
cd /tmp
export RATE=5
curl() { echo fake; }
curl x
Run with bash -x, this prints:
+ cd /tmp
+ export RATE=5
+ RATE=5
+ curl x
+ echo fake
fake
The trace shows the directory and the variable because the script set them. It shows curl x followed by an echo, which is the only hint that curl is a function here and not the program. If the function and the variable had come from a profile file, the trace would hold neither definition, and the receiver would run the real curl.
Run it where nothing is inherited#
env -i HOME="$(mktemp -d)" PATH=/usr/bin:/bin bash --noprofile --norc -eu steps.sh
env -i starts with an empty environment, and the options stop bash from reading its startup files. -u fails on a variable that you forgot to define. Each failure is a fact that the handoff was missing: add it to the script, or to a list of prerequisites if it is a secret. Never put the secret's value in the script.
The remaining differences are in files, installed versions and the network. Print the versions at the top of the script, with node --version and the like.
Record the status#
script records a session with its output. Its exit status is 0 unless you ask for the child's with -e:
| Command | Exit |
|---|---|
script -qc 'false' /dev/null | 0 |
script -qec 'false' /dev/null | 1 |
With -e, and a log file, the recording's last line was:
Script done on 2026-11-24 09:08:39+00:00 [COMMAND_EXIT_CODE="3"]
The file contains control characters, and everything that was displayed. A password typed at a prompt that does not echo is not displayed, while one on a command line or in a printed configuration is. Read the recording before you send it.
Choose the form#
| Receiver's task | Send |
|---|---|
| Repeat it | The script that passed in a clean shell |
| Check what you saw | The script, and the transcript with exit codes |
| Continue from the middle | The script up to that point, and the state it leaves |
| Judge whether a step was done in production | The audit record. Your terminal is a weaker source |
Make the script say what it expects#
End it with an assertion and not with output to be read by eye:
got=$(wc -l < export.csv)
[ "$got" -eq 10001 ] || { echo "expected 10001 lines, got $got"; exit 1; }
A receiver who gets a different number knows at once, and knows which number you had.
Worked example#
This example is fictional. Ana pastes her history into a ticket: six commands that rebuild a search index. Ben runs them and gets an empty index. Under env -i, Ana's own commands fail at the second with INDEX_ENV: unbound variable. Her profile exports it, and without it the tool silently uses a default. The script now fails when the variable is missing, and Ben decides which environment to rebuild instead of rebuilding the wrong one.
If output went through a pipe, its status may be lost. Return to handing over evidence.