Piping a command's output to tail silently hides its real exit status
A developer discovered on September 4, 2026, that running a Node.js script through a pipe to tail caused the shell to report exit code 0, even though the script had actually failed with exit code 1. This happens because in bash, the $? variable after a pipeline reflects the exit status of the last command in the pipe — in this case, tail — not the original program. The issue was especially problematic in a control run, where accurately capturing failure is critical, since a masked exit code made a genuinely failed check appear successful. The developer recommends either running the command on its own line, using bash's PIPESTATUS[0] array immediately after the pipeline, or enabling set -o pipefail in scripts, each with its own caveats. The bug was found by accident rather than deliberate auditing, and the author acknowledges similar issues may exist elsewhere in their codebase.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in