Skip to content

fix(fish): do not wrap an already wrapped script behind a leading line continuation - #5143

Open
Kernel-Hunter wants to merge 1 commit into
rtk-ai:developfrom
Kernel-Hunter:fix/fish-wrap-leading-continuation
Open

Kernel-Hunter wants to merge 1 commit into
rtk-ai:developfrom
Kernel-Hunter:fix/fish-wrap-leading-continuation

Conversation

@Kernel-Hunter

Copy link
Copy Markdown

Summary

  • try_wrap decides that a script already delegates to rtk by reading the first word of the trimmed text. Behind a leading \ and newline that first word is the \, so a command that is already rtk run --shell fish -c '...' gets wrapped a second time. Bash drops the continuation before running the command, so the first word is really rtk.
  • The check now reads the first word after collapse_line_continuations, the same helper the rewrite rules use. The result for the issue's two rows is the same: neither is wrapped.
  • The only visible effect of the bug was an extra ask prompt, since a settings deny still blocked the wrapped form.

Test plan

  • New unit test test_already_wrapped_script_behind_leading_continuation_is_not_wrapped_again covers the plain form, one continuation, and two continuations with indentation. It fails on develop and passes with this change.
  • cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings and cargo test --lib (4699 passed) pass on macOS.

Fixes #4923

…ding line continuation

try_wrap read the first word of the trimmed script, so a leading backslash and newline hid an existing rtk run --shell fish wrap and it was wrapped a second time. Read the first word after bash's line continuations are dropped, as the rewrite rules already do.

Fixes rtk-ai#4923
@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working fish hooks labels Nov 17, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes a bug in the fish script wrapping logic where a script already delegating to rtk run --shell fish would get wrapped a second time if preceded by a line continuation backslash. The fix makes try_wrap read the first word using the same collapse_line_continuations helper used by rewrite rules, so it correctly detects rtk as the first word in bash's eyes.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4923


Analyzed automatically by wshm · This is an automated analysis, not a human review.

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

Labels

bug Something isn't working fish hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fish wrap: a typed rtk run --shell fish -c behind a leading line continuation is wrapped again

1 participant