← Problem log

A pipe made a failed check look like a pass

Last verified Nov 7
By the Bluhook team · Updated Nov 8, 2026
Version 1
Exact text to search:
bash pipe hides exit code, && still runs after a failed check, set -o pipefail

1What happened

We run a quality check on every client email before it sends. The send only runs if the check passes: check && send.

One day we added "| tail -4" after the check so the output was shorter. The check failed, but the line still sent the email. A pipe returns the exit code of its last command, and tail succeeded.

So one client email went out before it had passed its check. The same text passed the check a few minutes later, so nothing wrong was said, but it should not have gone. The email also showed as one block of text, because the body's blank lines were never turned into paragraphs.

2What we did

  1. Removed the pipe. The check now writes its output to a file (check > out.txt 2>&1 && send), and we read the file after.

  2. Where a pipe is needed, set -o pipefail goes first, so any failed step fails the whole line.

  3. The send step now turns blank lines into paragraphs, so a body can't arrive as one block.

  4. The rule went into the instructions every sender on the team loads. The POSIX shell standard explains how a pipe reports its result. Google's SRE book has a Google SRE launch checklist and a Google SRE monitoring chapter about alerts people can act on.

3How we checked

We ran a step we knew would fail, three ways. With the pipe, the next step still ran. With output to a file, it did not. With set -o pipefail first, it did not. A second person on the team read the new rule back from the live instructions.

4Try it

Never pipe a gate: run "check > out.txt 2>&1 && send", or put "set -o pipefail" first. Other quiet failures were reviews that stopped quietly and a job that failed quietly. Our guide to agent monitoring shows how checks are watched.

shell scriptsquality checkssilent failuresPublished Nov 7

Your free AI evaluation

14 free questions, a few minutes. Add your email after question 9 to see your top jobs for AI.

Show me my top 3 jobs

Questions people ask

Why does && still run after a failed check in bash?

A pipe returns the exit code of its last command. We added "| tail -4" after our check, so tail succeeded even when the check failed. The next step ran anyway.

How do I use set -o pipefail to catch a failed step?

Put set -o pipefail first, so any failed step fails the whole line. Or skip the pipe: write the check's output to a file, as in check > out.txt 2>&1 && send, and read the file after.

Keep reading

Robb Lejuwaan

Every practical lesson, the wins and the flops, goes into Robb on AI, a free email newsletter.

Robb Lejuwaan, writer of Robb on AI
Get Robb on AI, free

Every lesson, win and flop, by email. Opens Substack.

Robb on AI is our free newsletter, written by Robb Lejuwaan.

We'll add you to Robb on AI, our free newsletter on Substack. Unsubscribe anytime. Privacy policy