Skip to content

fix(shell): capture before feeding a here-string, so a failed command is seen - #1231

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/clever-heisenberg-q9qp32-here-strings
Nov 24, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
claude/clever-heisenberg-q9qp32-here-strings

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

In consumer <<<"$(cmd)", bash keeps only consumer's exit status and discards cmd's. That holds under set -e, under pipefail, and with shopt -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 carries cmd'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 ran jq -r '.[].filename' on input that holds one object per file, not an array.
    • That jq call fails with exit 5 on every PR, and the here-string hid it. 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() (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.
    • 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 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 18 parse_rg_line calls (three subshells per match) become IFS=: read -r filepath linenum content <<<"$match".
    • It splits on the first two colons, as cut -f3- did.
    • Over 3006 rg lines the output is identical, except 2 lines whose content ends in |, which the old form dropped.
    • The scanner's JSON on a sample tree is identical: 26 findings.
  • The other sites:
    • security-check.sh: 4 sites, now sharing one helper, spdx_in_head
    • gen-rules-praxis.sh: 3 sites
    • check-standards-integration.sh, patch_phase2.sh, hypatia-cli-bash.sh and fix-missing-spdx.sh
    • ci.yml and security-policy.yml
    • test/ci-health-test.sh: 2 sites

Evidence

  • 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.sh and test/pr-automerge-sweep-test.sh pass. Against main's sweep, the new PR 18 case fails.
  • scripts/gen-rules-praxis.sh regenerates hypatia_rules_praxis.deed byte for byte.
  • check-standards-integration.sh: outcome=pass.
  • ShellCheck (-S warning) adds no warning in any touched file, and the scanner has three fewer.
  • actionlint 1.7.7, with ShellCheck on, reports the same 25 pre-existing findings on both workflows before and after.
  • RE012, run from the stacked branch over this tree: 0 findings. RE011 exposed findings: 0.

Beyond this repo

The same class turns up elsewhere in the estate, measured with grep '<<<"$('. These need follow-ups in their own repos:

Repo Sites
standards 5
.git-private-farm 3
mathesis 2
rsr-template-repo 1

Generated by Claude Code

… 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
@gitnotebooks

gitnotebooks Bot commented Nov 24, 2026

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8ecce494-6143-41e8-867c-e324ce6a11fd
Commits

Reviewing files that changed from the base of the PR and between d158aed and 7792b36.

Files selected for processing: 15

  • .github/workflows/ci.yml
  • .github/workflows/security-policy.yml
  • hypatia-cli-bash.sh
  • hypatia-scanner-v2.sh
  • scripts/check-readme-claims.sh
  • scripts/fix-scripts/fix-missing-spdx.sh
  • scripts/gen-rules-praxis.sh
  • scripts/security-check.sh
  • scripts/standards-integration/check-standards-integration.sh
  • scripts/sweeps/estate-pr-automerge.sh
  • scripts/sweeps/patch_phase2.sh
  • test/ci-health-test.sh
  • test/pr-automerge-sweep-test.sh
  • tests/readme-claims-test.sh
  • tests/rules-praxis-test.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T11:35:46.849910Z 7792b36 Draft marked ready
🔒 Security Review ✅ Completed 2026-11-24T11:31:45.613831Z 7792b36 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hyperpolymath
hyperpolymath merged commit 09c305d into main Nov 24, 2026
96 of 100 checks passed
@hyperpolymath
hyperpolymath deleted the claude/clever-heisenberg-q9qp32-here-strings branch November 24, 2026 11:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread hypatia-scanner-v2.sh
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants