piped-command-exit-code-masks-primary-script-result
When spot-checking script exit codes by piping output through tail or similar tools, the shell captures the last command’s exit code, not the primary script’s. This caused a false-positive C2 finding: both frontend-integrity-lint.py and frontend-integration-test.sh correctly exit 1 on failure, but the check script | tail -20; echo $? returned tail’s exit 0. Always capture exit code before piping: script; echo "exit=$?" or use ${PIPESTATUS[0]}.
Related
- piped-tail-masks-script-exit-code
- pipe-tail-corrupts-exit-code-verification
- pipe-through-tail-masks-script-exit-code
- pipe-tail-captures-tail-exit-not-script-exit
- pipe-tail-masks-script-exit-code
- pipe-through-tail-captures-tails-exit-code-not-scripts
- makefile-awk-help-regex-must-include-digit-character-class