Repository navigation
fix(shell): capture before feeding a here-string, so a failed command is seen - #1231
Conversation
… is seen (RE012 sites) `consumer <<<"$(cmd)"` keeps only `consumer`'s status; `cmd`'s failure is discarded under set -e, pipefail and inherit_errexit alike (bash 5.2.21). Every such site in the tree is rewritten to capture first, in an assignment whose status is `cmd`'s, and to say what a failed read means there. The rule that finds the class, RE012, follows in a stacked PR and finds none here. Real defects the here-strings hid: - scripts/sweeps/estate-pr-automerge.sh: the workflow check ran `jq -r '.[].filename'` on one object per file, which fails (exit 5) on every PR, so no workflow edit was ever classed `meta` and a doc under .github/workflows/ could be armed for auto-merge. It now reads `.filename` from the captured objects, and a failed read is classed meta. New sweep test cases (PRs 18 and 19) fail on main and pass here. - scripts/check-readme-claims.sh anchors(): runs in an `||` list, where errexit is off, so grep's exit 2 inside a pipeline was lost (CodeRabbit on #1208). Each read is now captured and checked. A new test injects a grep that fails for one file only; it fails on main and passes here. - tests/rules-praxis-test.sh row_has (CodeRabbit on #1208): a failed read of the deed returns 2 instead of reading as a missing fact. Rewritten without a behaviour change: - hypatia-scanner-v2.sh: the 18 `parse_rg_line` calls (three subshells per match) become `IFS=: read -r filepath linenum content <<<"$match"`, which splits on the first two colons as `cut -f3-` did. 3006 rg lines compared: identical except 2 whose content ends in `|`, which the old form dropped. The scanner's JSON on a sample tree is identical (26 findings). - security-check.sh (4 sites, one helper spdx_in_head), gen-rules-praxis.sh (3), check-standards-integration.sh, patch_phase2.sh, hypatia-cli-bash.sh, fix-missing-spdx.sh, ci.yml, security-policy.yml, test/ci-health-test.sh (2). Checked: tests/rules-praxis-test.sh 22/22; tests/readme-claims-test.sh 10/10; test/ci-health-test.sh and test/pr-automerge-sweep-test.sh pass; gen-rules-praxis.sh regenerates the deed byte for byte; check-standards-integration.sh pass; ShellCheck adds no warning in any touched file (three fewer in the scanner); actionlint 1.7.7 reports the same 25 pre-existing findings on both workflows before and after. RE012 on this tree: 0 findings; RE011 exposed: 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01J4QvDgzT72Tq2HTJmikyNg
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7792b36a49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [[ "$file" == *.rs ]]; then | ||
| while IFS= read -r match; do | ||
| IFS='|' read -r filepath linenum content <<< "$(parse_rg_line "$match")" | ||
| IFS=: read -r filepath linenum content <<<"$match" |
There was a problem hiding this comment.
Preserve trailing colons in matched source lines
When a matched line ends in :, Bash treats that final colon as an IFS delimiter and removes it from content; the previous cut -d: -f3- implementation preserved it. This affects every rewritten parser site and makes the finding's code field differ from the scanned source for inputs such as a directly scanned file containing a matching decodeJWT: line.
Useful? React with 👍 / 👎.



Summary
In
consumer <<<"$(cmd)", bash keeps onlyconsumer's exit status and discardscmd's. That holds underset -e, underpipefail, and withshopt -s inherit_errexit. Checked on bash 5.2.21:read -r v <<<"$(exit 3)"returns 0.This PR rewrites all 36 such sites in the tree to capture first,
out=$(cmd), so the assignment carriescmd's status, and says what a failed read means at each site. The rule that finds this class, RE012, follows as a stacked PR on this branch. With these fixes it finds nothing in hypatia.This also handles the two regressions CodeRabbit raised on #1208, which the owner decided on 2026-11-24 to cover with a rule: "a rule, every here-string".
Defects the here-strings were hiding
scripts/sweeps/estate-pr-automerge.sh: the workflow check ranjq -r '.[].filename'on input that holds one object per file, not an array.meta, and a doc under.github/workflows/could be armed for auto-merge..filenamefrom the captured objects, and a failed read is classed meta.scripts/check-readme-claims.shanchors()(CodeRabbit on fix(ci): stop piping into a quiet grep (RE011) #1208): the function runs in an||list, where errexit is off, so grep's exit 2 inside a pipeline was lost.grepthat fails for one file only. It fails on main and passes here.tests/rules-praxis-test.shrow_has(CodeRabbit on fix(ci): stop piping into a quiet grep (RE011) #1208): a failed read of the deed now returns 2, instead of reading as a missing fact.Rewritten with no change in behaviour
hypatia-scanner-v2.sh: the 18parse_rg_linecalls (three subshells per match) becomeIFS=: read -r filepath linenum content <<<"$match".cut -f3-did.rglines the output is identical, except 2 lines whose content ends in|, which the old form dropped.security-check.sh: 4 sites, now sharing one helper,spdx_in_headgen-rules-praxis.sh: 3 sitescheck-standards-integration.sh,patch_phase2.sh,hypatia-cli-bash.shandfix-missing-spdx.shci.ymlandsecurity-policy.ymltest/ci-health-test.sh: 2 sitesEvidence
tests/rules-praxis-test.sh: 22 passed.tests/readme-claims-test.sh: 10 passed. Against main's script, 9 passed and 1 failed: the new injected-fault case.test/ci-health-test.shandtest/pr-automerge-sweep-test.shpass. Against main's sweep, the new PR 18 case fails.scripts/gen-rules-praxis.shregenerateshypatia_rules_praxis.deedbyte for byte.check-standards-integration.sh:outcome=pass.-S warning) adds no warning in any touched file, and the scanner has three fewer.Beyond this repo
The same class turns up elsewhere in the estate, measured with
grep '<<<"$('. These need follow-ups in their own repos:.git-private-farmGenerated by Claude Code