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
Here is a piece of code I wrote to fix this, but I would like rtk to support it natively
Note: I use fish as a shell
function rtk_wrapper --description"Rewrite-first RTK command router with safe fallback"iftest (count$argv) -eq 0
echo"Usage: rtk_wrapper <command ...>">&2return 64
endset raw (string join"" -- $argv)
# Special case: shell -c "..." should rewrite the inner script, not only the wrapper command.iftest (count$argv) -ge 3
set shell_cmd $argv[1]
set shell_flag $argv[2]
ifcontains -- $shell_cmd fish sh bash zsh; andtest"$shell_flag" = "-c"set script $argv[3]
set passthrough_args $argv[4..-1]
set classification (__rtk_wrapper_classify "$script")
set action $classification[1]
set value (string join"\n" -- $classification[2..-1])
switch$actioncase rewrite
command$shell_cmd-c"$value"$passthrough_argsreturn$statuscase deny
echo"rtk_wrapper: denied by rtk rewrite policy: $script">&2return 2
endcommand$shell_cmd-c"$script"$passthrough_argsreturn$statusendendset classification (__rtk_wrapper_classify "$raw")
set action $classification[1]
set value (string join"\n" -- $classification[2..-1])
switch$actioncase rewrite
eval$valuereturn$statuscase deny
echo"rtk_wrapper: denied by rtk rewrite policy: $raw">&2return 2
end# Exit 1 (no rewrite) or any unexpected rewrite error: run raw command.eval$rawreturn$statusend# Internal helper: classify command into rewrite/raw/deny based on `rtk rewrite`.# Output format (stdout lines):# line 1: action (rewrite|raw|deny)# line 2+: command payloadfunction __rtk_wrapper_classify --argument-names cmd
set rewritten (rtk rewrite "$cmd"2>/dev/null)
set rewrite_status $statusswitch$rewrite_statuscase 0 3
iftest-n"$rewritten"printf"rewrite\n%s\n""$rewritten"return 0
endcase 2
printf"deny\n%s\n""$cmd"return 0
endprintf"raw\n%s\n""$cmd"end
@ccoVeille
No, not exactly. I was trying to fix a similar issue where Claude would consistently fail when running rtk run -c '<script>'. I came across this issue while investigating it, and since the underlying cause seemed related, I ended up fixing this one as well.
Retested on rtk 0.45.0 (Linux x86_64 / WSL2, 2026-08-08): the direct shell
carrier case still does not rewrite in the dry-run.
rtk hook check --agent claude bash -c 'git status'
Observed:
No rewrite for: bash -c git status
The new multiline-block rewrite works for independent newline-separated
commands, but it does not close this quoted bash -c carrier case. This is only
a current-version receipt; I am not proposing a naive eval/quote round-trip.
The existing safety constraints in this issue remain important.
Activity
ccoVeille commentedon Jul 1, 2026
Here is a piece of code I wrote to fix this, but I would like rtk to support it natively
Note: I use fish as a shell
pszymkowiak commentedon Jul 1, 2026
🔍 Automated Triage
featuremediumSummary
rtk rewrite does not recurse into bash -c / fish -c quoted arguments; request to rewrite the inner command string rather than silently emit nothing
Triaged automatically by wshm · This is an automated analysis, not a human review.
pashifika commentedon Jul 19, 2026
I believe this issue has been resolved by #3057. Please try it and let me know if it works for you.
fix(rewrite): handle quoted shell command wrappers
ccoVeille commentedon Jul 19, 2026
Thank you @pashifika
Did you experience a similar issue? Or did you look for issue you could try to fix.
pashifika commentedon Jul 19, 2026
@ccoVeille
No, not exactly. I was trying to fix a similar issue where Claude would consistently fail when running
rtk run -c '<script>'. I came across this issue while investigating it, and since the underlying cause seemed related, I ended up fixing this one as well.pavelbe commentedon Aug 8, 2026
Retested on
rtk 0.45.0(Linux x86_64 / WSL2, 2026-08-08): the direct shellcarrier case still does not rewrite in the dry-run.
rtk hook check --agent claude bash -c 'git status'Observed:
The new multiline-block rewrite works for independent newline-separated
commands, but it does not close this quoted
bash -ccarrier case. This is onlya current-version receipt; I am not proposing a naive
eval/quote round-trip.The existing safety constraints in this issue remain important.
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
feat(rewrite): read a quoted fish -c script as fish
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
feat(rewrite): read a quoted fish -c script as fish
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
feat(rewrite): read a quoted fish -c script as fish
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
feat(rewrite): read a quoted fish -c script as fish
fix(rewrite): rewrite inner commands of quoted sh/bash/zsh -c wrappers
feat(rewrite): read a quoted fish -c script as fish
chore: merge upstream v1.0.1