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
rewrite re-spells zsh's &! as & !, so under zsh the command after it no longer runs #4918
At top level the rewrite splits zsh's background-and-disown operator &! into & and !, then re-joins it spaced:
$ rtk rewrite "git status &!git log"
rtk git status & !git log (exit 0; same on rtk 1.1.0 and develop 4b4bc40d9)
In zsh the two spellings do different things. &! is one operator, so what follows it runs; spaced, !git is a command name:
$ zsh -c 'echo a &!echo HIT'
a
HIT
$ zsh -c 'echo a & !echo HIT'
a
zsh:1: command not found: !echo
So when the agent's shell is zsh, the rewritten command silently drops the second command. In bash and dash both spellings fail the same way (!echo: command not found), so nothing changes there.
Scope
Inside a zsh -c or fish -c script the rewrite already refuses these pairs (disown_pair / opens_disown_pair, #4126; #4517 tracks cleanups there). The top-level line is read as POSIX, so the same check is not applied there. &| is kept as written (rtk git status &|git log).
Fix direction
Either keep the pair glued when re-emitting a segment boundary that a ! follows, or have the top-level rewrite refuse a line that opens a disown pair, as the wrapped-script path does.
The permission check has to move with it. With deny: ["Bash(rm:*)"] and allow: ["Bash(*)"], develop answers git status &!rm -rf /tmp/example with an allow and the rewrite rtk git status & !rm -rf /tmp/example. Only the re-spelling keeps zsh from running rm there. Once the pair stays glued, the deny scan must read the command after &! as its own segment at top level too. The shell is not known at top level, and bash and sh never run a glued !rm, so a boundary that ignores the dialect costs nothing there.
zsh 5.9.2 (Docker), rtk built from develop 4b4bc40 and rtk 1.1.0.
Top-level rewrite re-spells zsh's &! disown operator as & !, silently dropping the following command under zsh and also weakening the deny-scan security boundary.
The re-spelling is fixed in v1.2.0. Since #4132 the rewrite copies the text between commands byte for byte instead of rebuilding each operator with spaces, so rtk rewrite "git status &!git log" now returns rtk git status &!git log, and zsh runs both commands as typed (checked with zsh 5.9.2). &| is kept as written too.
A correction to the report above: develop at 4b4bc40 already kept the pair glued (rebuilt and checked); only v1.1.0 re-spelled it.
The permission-scan point in "Fix direction" is being picked up separately with the lexer work, so closing this one.
Activity
rtk-wshm-sync-bot commentedon Nov 1, 2026
🔍 Automated Triage
bughighSummary
Top-level rewrite re-spells zsh's
&!disown operator as& !, silently dropping the following command under zsh and also weakening the deny-scan security boundary.📁 Relevant files
src/rewrite.rsSuggested Actions
Argarm, a redundant second call, and the&!rule applied to fish where both spellings agree #4517) for the top-level POSIX rewrite path&!as its own command at top levelgit status &!rm -rf /tmp/examplewith deny:["Bash(rm:*)"] must be denied, not rewritten with a…Triaged automatically by wshm · This is an automated analysis, not a human review.
fix(permissions): read zsh's disown operator in a wrapper's deny scan
fix(permissions): check the command after zsh's &! disown operator (#46)
KuSh commentedon Nov 8, 2026
The re-spelling is fixed in v1.2.0. Since #4132 the rewrite copies the text between commands byte for byte instead of rebuilding each operator with spaces, so
rtk rewrite "git status &!git log"now returnsrtk git status &!git log, and zsh runs both commands as typed (checked with zsh 5.9.2).&|is kept as written too.A correction to the report above: develop at 4b4bc40 already kept the pair glued (rebuilt and checked); only v1.1.0 re-spelled it.
The permission-scan point in "Fix direction" is being picked up separately with the lexer work, so closing this one.