Repository navigation
A command whose exit status its script throws away is advisory (|| true, pipes without pipefail, sequences without set -e, conditions) - #338
Merged
Conversation
`cmd || true`, a pipe without pipefail, a command followed by others without set -e, one before && in the middle of a script under set -e, a condition (if, elif, while, until, !) and a background command cannot fail CI. Each is now advisory, with the reason. The shell decides which apply: GitHub's default bash -e versus shell: bash's -eo pipefail, GitLab's set -eo pipefail, sh -c for make recipe lines and package scripts, a script's own shell command or shebang, and set along the way. make's and just's `-` prefix ignores a line's failure. A fallback that fails again, or tests $? (zig's `|| [ $? -eq 124 ]`), keeps the failure, as does a status the next command reads. Part of cpp-best-practices#334 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #338 +/- ##
========================================
Coverage 99.75% 99.75%
========================================
Files 298 299 +1
Lines 17971 18136 +165
Branches 2055 2086 +31
========================================
+ Hits 17927 18092 +165
Misses 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #334.
A command whose exit status its script throws away can't fail CI, but until now it counted as a gate. Only
continue-on-errorandallow_failuremade a run advisory. Now each command's place in its script decides it too. A masked run is advisory, with the reason, and checks say so:ruff format runs in CI but cannot fail it (|| true).What counts as masked
cmd; otheror a later line, withoutset -efollowed by other commands without set -ecmd && other, then more lines, underset -e(errexit ignores it)before && in the middle of the scriptif cmd,elif,while,untilan if condition, …! cmdnegated by !cmd &run in the backgroundIt is not masked when:
|| exit 1,|| exit,|| false,|| { …; exit 1; };|| [ $? -eq 124 ], which zig's fuzzing uses to accepttimeout);$?orPIPESTATUS;A fallback group that goes on past its line isn't read, so it isn't judged. Commands inside
$(…)aren't judged.Which shell runs the script
bash -e {0}: errexit, no pipefail;shell: bash(ordefaults.run.shell) is-eo pipefail;shis-e;bash -l {0}-style wrapper is read for its flags;set -eo pipefail. Each script line is read on its own, so only fallbacks, pipes without pipefail and conditions apply. Windows (PowerShell) isn't judged.sh -c, with no errexit. make's-prefix, and just's, ignores the line's failure (make ignores its failure (-)).bash -e ci/lint.sh), or from its shebang when it runs itself (#!/bin/bash -e). A sourced script (. ci/env.sh) isn't judged.set -e,set +e,set -o pipefailandset -euo pipefailchange the options from that point on.How it's built
facts/shell.py: eachShellCommandnow carries what decides its status:||fallback, if that fallback can succeed;facts/exit_status.py(new):Shell(errexit, pipefail),shell_ofandset_options(read-eo pipefailand the like), andmasked, which walks a script and gives each command its reason.script_factstakes theshell.Scriptcarriesshellandadvisoryfor expansions.-can be read;tests/test_expansion.pychanges to match.Corpus snapshots, checked by hand
Four
.facts.jsonsnapshots change, and no result does:well_configured_cand_cpp:find … | xargs clang-format …makesfindadvisory. That's right, and find isn't a tool.well_configured_kubernetes:helm template charts/shop | kubeconform …makeshelm templateadvisory. That's right: if helm fails, kubeconform validates empty input and passes.well_configured_lua:curl … | tar xzmakescurladvisory. That's right, and harmless.The first run also flagged zig's
timeout 60 zig build fuzz || [ $? -eq 124 ], a false positive that turned fuzz-testing into WARN. A fallback that tests$?now counts as failing again, with a test.Not covered
PowerShell (
$ErrorActionPreference,$LASTEXITCODE) isn't judged yet; #334's fifth pattern says "possibly later". GitLab lines are read one at a time, socmd && otherin the middle of a GitLab script isn't caught.Gates
Run with the fixed gate script, which checks every step's own exit status: ruff, ruff format, mypy, lizard (length ≤ 30), tests (2,473 OK, 13 expected failures), coverage (99%; the new and changed lines are all covered), jscpd (0 clones) and strict self-validation all pass. One test, for a shell an expression names, was added after the run; I checked it fails without its code and passes with it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt