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
collapse_line_continuations fuses commands when the backslash before a newline is escaped (\\<newline>) #3190
collapse_line_continuations (src/discover/registry.rs, LINE_CONTINUATION_RE) treats every \<newline> as a bash line continuation. But when the backslash is itself escaped — \\<newline> — bash sees a literal backslash followed by a command separator: two independent commands. The regex matches the second backslash + newline and collapses them to a space, fusing the two commands into one before rewriting.
Reproduction (rtk 0.43.0 and develop)
Input (literal \\ then newline):
git add path\\
git status
Bash runs two commands: git add 'path\' then git status (verify: printf one\\ ; printf two split across lines prints [one\][two]).
rtk rewrite / the hook instead produce:
rtk git add path\ git status
— one fused command with an rtk prefix, where bash saw a command boundary. git status is silently consumed as arguments to git add.
Suggested fix
Make the continuation regex require an odd number of preceding backslashes (an even count means the final backslash is escaped/literal and the newline is a real separator).
Found while adversarially testing #3188 (which does not touch this code path; the collapse runs before the multi-line handling added there).
collapse_line_continuations incorrectly treats an escaped backslash (\) as a bash line continuation, silently fusing two independent commands (e.g. git status becomes an argument to git add); fix regex in src/discover/registry.rs (LINE_CONTINUATION_RE) to require an odd count of preceding backslashes.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/discover/registry.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Activity
pszymkowiak commentedon Jul 24, 2026
🔍 Automated Triage
bughighSummary
collapse_line_continuations incorrectly treats an escaped backslash (\) as a bash line continuation, silently fusing two independent commands (e.g.
git statusbecomes an argument togit add); fix regex in src/discover/registry.rs (LINE_CONTINUATION_RE) to require an odd count of preceding backslashes.📁 Relevant files
src/discover/registry.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
nightcityblade commentedon Jul 24, 2026
Hi, I'd like to work on this. I'll submit a PR shortly.