You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A case (or subshell / brace group) anywhere on a line disables rewriting of every pipeline on that line #4283
A case statement anywhere on a command line disables the rewrite of any pipeline anywhere else on that line — including a pipeline in a different segment. The same happens for a subshell or a brace group sharing a line with a pipe.
This is a conservative miss, not corruption: the command runs as written. It is filed because it survives #3343's safe-consumer rewrite, so it is what still keeps the shapes in #3722 unrewritten once a case, ( ) or { } is on the line.
Repro
rtk rewrite at the tip of the lexing stack (#4138, a4e60f84); the plain-pipe row is the control.
command
result
git status | cat
rtk git status | cat
case x in x) git status;; esac | cat
not rewritten
git status | cat; case x in x) echo 1;; esac
not rewritten
ls -la | head -3; case x in x) echo 1;; esac
not rewritten
(git status) | cat
not rewritten
{ git status; } | cat
not rewritten
The two bold rows are the cost: the case and the pipeline are separate commands, and the pipeline would rewrite on its own.
Cause
rewrite_compound in src/discover/registry.rs bails before it segments anything:
The check is over the whole line, and a case pattern's closing ) counts as grouping. So one ) anywhere, plus one | anywhere, and nothing on the line is looked at.
What makes it fixable now
#4135 added CaseTracker to the lexer, which both segmenters consult so that a pattern's ( is not read as a subshell. The same tracker knows which ) closes a pattern, so has_opaque_grouping could skip those — and, more generally, the check could be made per segment rather than per line, so a pipeline in one segment is judged on its own rather than on what sits beside it.
The subshell and brace-group rows are the same check with a different bracket. Whether those should rewrite inside a pipeline is a separate question from whether a case elsewhere on the line should block a pipeline that has nothing to do with it.
Related: #3722 (the general pipe skip; this is its residue after #3343), #3197 (where the case row was noticed while re-testing the ;; fix), #4135 (CaseTracker).
A case/subshell/brace-group anywhere on a line makes rewrite_compound bail on the whole line's pipelines instead of checking per segment via CaseTracker.
Activity
rtk-wshm-sync-bot commentedon Sep 26, 2026
🔍 Automated Triage
bugmediumSummary
A
case/subshell/brace-group anywhere on a line makesrewrite_compoundbail on the whole line's pipelines instead of checking per segment via CaseTracker.📁 Relevant files
src/discover/registry.rsSuggested Actions
has_opaque_groupingto exclude)that closes a case patternrewrite_compound(git status) | cat,{ git status; } | cat) should rewrite;;into; ;, breaking everycasestatement (bash syntax error) #3197 when implementing the segment-level fixTriaged automatically by wshm · This is an automated analysis, not a human review.