Repository navigation
fix(rules): case arms inside $(...), escaped operators before & - #1143
Conversation
The two Codex edge cases #1129 left as stated limits: - shell_mask: the word `case` at a command start pushes :case and `esac` pops it. While :case is on top, a `)` ends a pattern, not the enclosing `$(...)`, so `v=$(case yes in yes)# ...` is a comment and `$(case y in y) echo;; esac)#x` still closes the substitution. - WF033 later_command?/1: backslash-escaped bytes are literals, so in `echo \>& echo done` the `&` is a separator, not part of `>&`. Tests for both fail without the change. A guard test checks that `case` as an argument opens nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT
|
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 10 minutes. 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: 42e6416a35
ℹ️ 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".
Codex on #1143: in `v=$(if true; then case yes in yes)# ...` the byte before `case` belongs to `then`, so command_start?/1 refused it, the pattern's `)` closed the substitution and the comment stayed visible. A reserved word that a command follows (then, do, else, elif, if, while, until, !, {) now counts as a command start, provided it starts a command itself; `echo then case` still opens nothing. Test "a case after then or do opens a case too" fails without this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT
Codex on #1143: in `$(case esac in yes)# ...` the subject `esac` popped :case, so the pattern's `)` closed the substitution and the comment stayed visible. `case` now pushes :case_head; the word `in` turns it into :case, and only then does `esac` close it. A `)` under either state ends a pattern and pops nothing. Test "esac as the case subject does not close the case" fails without this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT
|
The red Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94c79682ec
ℹ️ 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".
Codex on #1143: `esac>/dev/null)` was not recognised as `esac`, so the substitution's `)` was taken as another pattern end and the live `#suffix --hypatia-ref` was masked. `<` and `>` now end the words `case`, `in` and `esac`. Test "esac with a redirection attached still closes the case" fails without this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT
|
Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68c010dd5f
ℹ️ 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".
Codex on #1143: - `time` and `coproc` join the reserved words a command follows. - `(` ends the words `case`, `in` and `esac`, so `in(x)` enters the body. - A separator escaped with a backslash (`\;`, `\` newline) is not a command start, so `echo \; case ...` opens nothing. Each has a test that fails without the change. Not done: `case` as a literal pattern alternative (`x|case)`) still opens a nested case; telling a pattern position from a command position needs a real parser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f010a27080
ℹ️ 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".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f7e944dea
ℹ️ 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".
|
|
||
| defp mask(<<?), r::binary>>, nil, _, _, qs?, ps, acc) do | ||
| case ps do | ||
| [top | _] when top in [:case, :case_head] -> mask(r, nil, true, false, qs?, ps, [?) | acc]) |
There was a problem hiding this comment.
Recognize a nested case at the start of a case arm
When an outer arm starts a nested case on the same line, as in case a in a) case b in ..., this pattern-closing ) sets whitespace state but leaves no indication that the next token is at a command start, so command_start?/1 rejects the nested case. Its esac then pops the outer case state, and a later outer pattern ) can incorrectly close the surrounding $(...), leaving a following commented pin visible to check_hypatia_pin_drift; preserve the case-arm command-start context after this delimiter.
Useful? React with 👍 / 👎.



What
This PR fixes the two Codex edge cases that #1129 left as stated limits (threads 4575524786 and 4575524789).
Hypatia.Workflow.shell_mask/2: the wordcaseat the start of a command pushes:case, andesacpops it. While:caseis on top, a)ends a pattern, not the enclosing$(…).v=$(case yes in yes)# …is now a comment.$(case y in y) echo;; esac)#xstill closes the substitution, so#xis part of the word.later_command?/1: backslash-escaped bytes are literals. Inecho \>& echo done, the&is a separator, not part of a>&redirection.Why
The owner asked for both to be fixed rather than left as limits.
Evidence
main(219 tests, 3 failures) and pass with this change:mix test test/rules test/soundness_test.exs:984 tests, 0 failures.mix format --check-formattedpasses on the changed files, as dogen-rules-praxis.sh --check,check-readme-claims.shandrules-praxis-test.sh.Not done
$((…))arithmetic and(inside double quotes are still not tracked.Generated by Claude Code